17. Common Mistake #1:
Incorrect references
to this
The 10 Most Common Mistakes
JavaScript Developers Make
by Ryan J. Peterson
18. function Product(name, cost, tax) {
if (!(this instanceof Product)) {
throw new Error("Constructor called as a function")
}
this.name = name
this.cost = cost
this.tax = tax
}
Product("Banana", 2, "%30")
37. /* @flow */
function crazy() : number | string | Array<null> {
const rand = Math.random()
if (rand > .5) {
return 0
}
if (rand < .5) {
return []
}
return rand.toString()
}
const ops : number | string | Array<null> = crazy()
Type smells!
38. A Type System is,
first and foremost,
a communication
mechanism
Tweet by Sarah Mei
39. A Type System replaces
direct communication
with other humans, when
such communication isn't
practical - large teams,
open source, etc
Tweet by Sarah Mei
42. interface ItemsResponse {
results: string[]
}
http.get<ItemsResponse>('/api/items')
.subscribe(data => {
this.results = data.results
})
It should return a
result property
with an array of
strings
from Angular documentation
95. It’s an incredible blessing,
that we went from 0 viable
ways to do FP in the browser
to 4 in just a few years
JavaScript vs Elm vs PureScript vs
GHCjs vs Scalajs by Isaac Shapira