JavaScript
Links
Cheat sheet
Objects
const object = {
a: 'somestring',
b: 42,
c: false
}
Object.keys() - returns an array with object keys.
Object.keys(object) => ["a", "b", "c"]
Object.values() - returns an array of object values, omit keys.
Object.values(object) => ["somestring", 42, false]
Object.entries() - returns an array with [key, value]
pairs.
for (let [key, value] of Object.entries(object)) {
console.log(`${key}: ${value}`)
}
// expected output:
// "a: somestring"
// "b: 42"
// order is not guaranteed
Object.freeze() - prevent object mutations.
console.log() with css styles
console.log('%cyou are awesome :)', 'color: white; font-size: 46px')
Last updated
Was this helpful?