Answers for "how to get object keys from value"

7

js get object keys

myObject = {
	"key": "value"
}

Object.keys(myObject); // get array of keys
Posted by: Guest on March-29-2020
1

Return the Objects Keys and Values

const keysAndValues = (obj) => [Object.keys(obj), Object.values(obj)];

keysAndValues({a: 1, b: 2, c: 3}); 
//➞ [["a", "b", "c"], [1, 2, 3]]

keysAndValues({a: "Dell", b: "Microsoft", c: "Google"}));
//➞ [["a", "b", "c"], ["Dell", "Microsoft", "Google"]]

keysAndValues({key1: true, key2: false, key3: undefined});
// ➞ [["key1", "key2", "key3"], [true, false, undefined]]
Posted by: Guest on April-22-2021

Code answers related to "how to get object keys from value"

Code answers related to "Javascript"

Browse Popular Code Answers by Language