[Solved] How to get only first object value key value [closed]


Just use array[0].value:

var array = [{
    label: "1",
    value: "11"
  },
  {
    label: "2",
    value: "22"
  },
  {
    label: "3",
    value: "33"
  },
  {
    label: "4",
    value: "44"
  },
];

var firstValue = array[0].value;
console.log(firstValue);

You can also use destructuring like so:

var array = [{
    label: "1",
    value: "11"
  },
  {
    label: "2",
    value: "22"
  },
  {
    label: "3",
    value: "33"
  },
  {
    label: "4",
    value: "44"
  },
];

var [{ value: firstValue }] = array;
console.log(firstValue);

1

solved How to get only first object value key value [closed]