a
a
aizatto.com
Build.my
GitHub
Linkedin
Notion
Search…
aizatto.com
Table of Contents
Portfolio, Projects, Tools, Toys
Interview Guide
Engineering Code
Engineering Management
Why GitBook?
Getting into Tech
Personal Goals
Daily Drivers
Contacting Me
Notes
AWS
JavaScript
Array
Async & Await / Promises
Booleans
Collections
Cons/Dislikes
fetch
Map
Modules
Object
Regex
Set
Style Guides
Versions
Node.js
Software Engineering
Technical Due Diligence
Web Development
Archive
More on Notion
Powered By
GitBook
Object
Clone an object
1
const
clone
=
Object
.
assign
({},
original
);
Copied!
Note: Doesn't do deep cloning. Use
lodash
or
underscore
Iterate keys in an object
(for...in)
1
const
object
=
{
x
:
'a'
,
y
:
'b'
,
z
:
'c'
}
2
for
(
const
key
in
object
)
{
3
console
.
log
(
`
${
key
}
:
${
object
[
key
]
}
`
);
4
}
Copied!
Result:
1
x: a
2
y: b
3
z: c
Copied!
​
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of
​
Iterate values in an object
(for...of)
Do not use `(for...of)` with `objects`. This will fatal with:
Safari:
1
TypeError: page[Symbol.iterator] is not a function. (In 'page[Symbol.iterator]()', 'page[Symbol.iterator]' is undefined)
Copied!
Chrome:
1
Uncaught TypeError: page[Symbol.iterator] is not a function
Copied!
​
Previous
Modules
Next
Regex
Last modified
3yr ago
Copy link
Contents
Clone an object
Iterate keys in an object (for...in)
Iterate values in an object (for...of)