get all keys and values from object javascript code example
Example 1: Return the Objects Keys and Values
const keysAndValues = (obj) => [Object.keys(obj), Object.values(obj)];
keysAndValues({a: 1, b: 2, c: 3});
keysAndValues({a: "Dell", b: "Microsoft", c: "Google"}));
keysAndValues({key1: true, key2: false, key3: undefined});
Example 2: javascript object get value by key
const person = {
name: 'Bob',
age: 47
}
Object.keys(person).forEach((key) => {
console.log(person[key]);
});
Example 3: get all keys from pbject javascirpt
const object1 = {
a: 'somestring',
b: 42,
c: false
};
console.log(Object.keys(object1));