Answers for "javascript object properties to array"

20

js object length

var person={
    "first_name":"Harry",
    "last_name":"Potter",
    "age":14
};
var personSize = Object.keys(person).length; //gets number of properties (3)
Posted by: Guest on July-22-2019
34

object keys javascript

const object1 = {
  a: 'somestring',
  b: 42,
  c: false
};

console.log(Object.keys(object1));
// expected output: Array ["a", "b", "c"]
Posted by: Guest on March-12-2020
4

get all entries in object as array hjs

const object1 = {
  a: 'somestring',
  b: 42
};

for (let [key, value] of Object.entries(object1)) {
  console.log(`${key}: ${value}`);
}

// expected output:
// "a: somestring"
// "b: 42"
// order is not guaranteed
Posted by: Guest on April-23-2020

Code answers related to "javascript object properties to array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language