Object
const clone = Object.assign({}, original);
Note: Doesn't do deep cloning. Use
lodash
or underscore
const object = {x: 'a', y: 'b', z: 'c'}
for (const key in object) {
console.log(`${key}: ${object[key]}`);
}
Result:
x: a
y: b
z: c
Do not use `(for...of)` with `objects`. This will fatal with:
Safari:
TypeError: page[Symbol.iterator] is not a function. (In 'page[Symbol.iterator]()', 'page[Symbol.iterator]' is undefined)
Chrome:
Uncaught TypeError: page[Symbol.iterator] is not a function
Last modified 4yr ago