Skip to content

9oelM/20-days-of-restudying-javascript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

rjs

(re)studying javascript

Prerequisites

  • Have read the latest edition of "Learning javascript" at least three times.
  • Have read "You Don't Know JS" at least once
  • Have coded substantial amount of javascript already
  • Now wanting to get some really fine techniques on javascript

Day 1

Read Airbnb's javascript style guide:

Clearing up questions for Day 1

1. Array.prototype.slice() in 4.5:

The slice() method returns a shallow copy of a portion of an array into a new array object selected from begin to end (end not included). The original array will not be modified.

  • Q: slice works on objects?
  • A: Slice method can also be called to convert Array-like objects / collections to a new Array.. So you could do something like:
    const info = Array.prototype.slice.call({0: "Korea", 1: "KST", length: 2}) // ["Korea", "KST"]
    Remember you need to specify the length, and the object keys should be indices. The following would result in nothing but an empty array:
    const info = Array.prototype.slice.call({home: "Korea", time: "KST"}) // []
    But anyways, it's not recommended to use Array.prototype.slice, but Array.from.

2. Array.from in 4.6

  • Q: So what can Array.from actually do with mapping?
  • A: This:
    Array.from can receive a mapping function as the second argument, as such:
    const mapped = Array.from([1,2,3], elem=>elem*2) // 2,4,6

Day 2

Read Airbnb's javascript style guide:

Things that I think it would be hard to remember for Day 2

  1. 14.2 Anonymous function expressions hoist their variable name, but not the function assignment.
  2. 14.3 Named function expressions hoist the variable name, not the function name or the function body.

Day 3

Read Airbnb's javascript style guide:

Things that I find useful for Day 3

Releases

No releases published

Packages

No packages published