✨ object의 keys 또는 values를 array로 반환하는 helper method
💻Example Code
const obj = { a: 'something', b: 2, c: 3 };
console.log( Object.keys(obj) );
console.log( Object.values(obj) );
😋 Anagrams(철자를 바꾼 말) Algorithm 에서 같은 종류의 철자가 사용되었는지 확인할 때 유용하게 사용하였다.
(Algorithm 카테고리의 Anagrams Algorithm 문제에서 확인 가능하다)
이 외에도 다양한 곳에서 사용 가능하다.
👉 자세한 내용은 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
Object.keys()
The Object.keys() method returns an array of a given object's own enumerable property names, in the same order as we get with a normal loop.
developer.mozilla.org
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values
Object.values()
The Object.values() method returns an array of a given object's own enumerable property values, in the same order as that provided by a for...in loop (the difference being that a for-in loop enumerates properties in the prototype chain as well).
developer.mozilla.org
'JavaScript > Built-in Method etc.' 카테고리의 다른 글
Array.prototype.fill() (0) | 2019.12.29 |
---|---|
String.prototype.replace() (0) | 2019.12.29 |
Array.prototype.sort() (0) | 2019.12.28 |
String.prototype.toLowerCase() & toUpperCase() (0) | 2019.12.28 |
Array.prototype.includes() (0) | 2019.12.26 |