📒
wiki
  • Introduction
  • Coding
    • Git
    • NPM
    • Yarn
    • VIM
    • tmux
    • Terminal
    • HTML
    • Node
    • JavaScript
      • Types
    • TypeScript
    • React
    • Jest
    • FLow
    • Functional programming
    • Data Structures
    • Coding Exercises
    • Design Systems
    • VSCode
  • Learn
    • Languages
  • Health
  • Bikes
  • Ideas
  • Journals/Wiki
  • Looking back
    • 2019
      • September
      • October
      • November
      • December
Powered by GitBook
On this page
  • Links
  • Cheat sheet
  • Objects
  • console.log() with css styles

Was this helpful?

  1. Coding

JavaScript

PreviousNodeNextTypes

Last updated 3 years ago

Was this helpful?

Links

Cheat sheet

Objects

const object = {
  a: 'somestring',
  b: 42,
  c: false
}

- returns an array with object keys.

Object.keys(object) => ["a", "b", "c"]

- returns an array of object values, omit keys.

Object.values(object) => ["somestring", 42, false]

- 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

console.log() with css styles

console.log('%cyou are awesome :)', 'color: white; font-size: 46px')

- prevent object mutations.

Design Patterns
Eloquent javascript
JS the right way
Object.keys()
Object.values()
Object.entries()
Object.freeze()