일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- CSS
- javascript
- addEventListener
- keyup
- node
- for loop
- node.js
- modal
- react
- ES5
- keyboardEvent
- yet
- Event
- innerHTML
- js
- TypingEffect
- Temporal dead zone
- innerText
- css:position
- a11y
- Review
- Dom
- textContent
- dotenv
- Empty
- nodeValue
- beforeinput
- HTML
- es6
- UI
- Today
- Total
the murmurous sea
JS: Object.keys() & Object.values() & Object.entries() 본문
Object.keys()
1. method
2. iterated in the same order that a normal loop would.
[Syntax]
Object.keys(obj)
[Return Value]
An array
: of strings
: of a given object's own enumerable property names
: that represent all the enumerable properties of the given object.
: The ordering of the properties is the same as the obj.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
Object.values()
1. method
2. in the same order as that provided by a for...in loop.
3. (The only difference is that a for...in loop enumerates properties in the prototype chain as well.)
[Syntax]
Object.values(obj)
[Return Value]
An array
: containing the obj's own enumerable property values.
: The ordering of the properties is the same as that given by looping over the property values of the object manually.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values
Also, check this article:
https://gomakethings.com/why-isnt-there-an-object.foreach-method/
Object.entries()
1. method
2. in the same order as that provided by a for...in loop.
3. (The only important difference is that a for...in loop enumerates properties in the prototype chain as well).
4. The order of the array returned by Object.entries() does not depend on how an object is defined.
: If there is a need for certain ordering, then the array should be sorted first.
- Object.entries(obj).sort((a, b) => b[0].localeCompare(a[0]));
[Syntax]
Object.entries(obj)
[Return Value]
An array
: of the obj's own enumerable string-keyed property [key, value] pairs.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries
'#dev > 개념정리' 카테고리의 다른 글
JS: call() and apply() (0) | 2020.05.13 |
---|---|
for...in & for...of (0) | 2020.05.13 |
유사 배열 객체(empty) (0) | 2020.05.12 |
Objects and Arrays(yet done) (0) | 2020.05.12 |
Object literal (empty) (0) | 2020.05.12 |