Last active
April 29, 2021 17:27
-
-
Save albertywu/eaff781246a08ecbb7d3329f29085360 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const o = { foo: 1, bar: 2 } | |
| const a = [1, 2, 3] | |
| // iterate over keys in object | |
| for (prop of Object.keys(o)) { | |
| console.log(prop) | |
| } | |
| // iterate over values in object | |
| for (value of Object.values(o)) { | |
| console.log(value) | |
| } | |
| // iterate over values in array | |
| for (value of a) { | |
| console.log(a) | |
| } | |
| // check if key is in object | |
| console.log('foo' in o) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment