Blake Newman / @blakenewman
const f = o => o.x
f({ x: 1 })
f({ x: 2 })
f({ x: 4 }) // monomorphic, degree 1
f({ x: 4, y: 1 }) // polymorphic, degree 2
f({ x: 5, z: 1 }) // polymorphic, degree 3
f({ x: 6, a: 1 }) // polymorphic, degree 4
f({ x: 7, b: 1 }) // megamorphic
class Point {
constructor(x, y) {
this.x = x
this.y = y
}
}
class Point2 {
constructor(x, y) {
this.x = x
this.y = y
}
}
const a = new Point(1, 2)
const b = new Point2(1, 2)
const c = { x: 1, y: 2 }
const d = { x: 1, y: 2, z: 3}
delete d.z
class Point {
constructor(x, y) {
this.x = x
this.y = y
}
}
const a = Point(1, 2)
const b = Point(1, 3) // Same shape
a.z = 2 // Different shapes
const f = o => o.x * o.x - o.y / o.y
f({ x: 1, y: 1 })
.x .x * .y .y / +
Why
How
Benefits
20% off
MEETUP-VJS-20
Competition Time
2 Free tickets