Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Print object keys

// Object.key()

let users = {
  Alan: {
    age: 27,
    online: false,
  },
  Jeff: {
    age: 32,
    online: true,
  },
  Sarah: {
    age: 48,
    online: false,
  },
  Ryan: {
    age: 19,
    online: true,
  },
};

function getArrayOfUsers(obj) {
  return Object.keys(obj); // [ 'Alan', 'Jeff', 'Sarah', 'Ryan' ]
}

console.log(getArrayOfUsers(users));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Print #object #keys
ADD COMMENT
Topic
Name
9+3 =