@wmsbill
this in the global scope
Browser - window
Web worker - self
NodeJS - module.exports
Slide 6
Slide 6 text
@wmsbill
this inside a function?
Slide 7
Slide 7 text
@wmsbill
this inside a function?
Slide 8
Slide 8 text
@wmsbill
What is this?
Slide 9
Slide 9 text
@wmsbill
What is this?
Slide 10
Slide 10 text
@wmsbill
this inside a function
Browser - window
NodeJS - global object
Slide 11
Slide 11 text
@wmsbill
this with new operator
Slide 12
Slide 12 text
@wmsbill
this with new operator
Slide 13
Slide 13 text
@wmsbill
this with strict mode
Slide 14
Slide 14 text
@wmsbill
this with strict mode
Slide 15
Slide 15 text
@wmsbill
Setting this value
Function.prototype.call
Function.prototype.apply
Function.prototype.bind
new operator
Object member function
Slide 16
Slide 16 text
@wmsbill
Setting this value
Slide 17
Slide 17 text
@wmsbill
How to make this predictable?
Reasoning the value of this is tricky
Function.prototype.bind
Arrow function () => {}
Slide 18
Slide 18 text
No content
Slide 19
Slide 19 text
With .bind()
Slide 20
Slide 20 text
With Arrow
Slide 21
Slide 21 text
@wmsbill
Calling a knowing function
Slide 22
Slide 22 text
@wmsbill
Extracting a method from an object
Slide 23
Slide 23 text
No content
Slide 24
Slide 24 text
@wmsbill
Two syntaxes
Unary : :context.method()
Binary context: :method()
Slide 25
Slide 25 text
@wmsbill
Unary syntax
Slide 26
Slide 26 text
@wmsbill
Binary syntax
Slide 27
Slide 27 text
@wmsbill
Slide 28
Slide 28 text
@wmsbill
Slide 29
Slide 29 text
@wmsbill
Slide 30
Slide 30 text
@wmsbill
Bind operator is good for virtual
methods
But relies on this to be bound
Slide 31
Slide 31 text
@wmsbill
Composing without this
Slide 32
Slide 32 text
@wmsbill
Slide 33
Slide 33 text
@wmsbill
Slide 34
Slide 34 text
No content
Slide 35
Slide 35 text
@wmsbill
Pipeline operator |>
It is a syntax sugar for
function composition
It creates a way to streamline
a chain of functions
Slide 36
Slide 36 text
@wmsbill
Pipeline operator |>
Slide 37
Slide 37 text
@wmsbill
Slide 38
Slide 38 text
@wmsbill
Slide 39
Slide 39 text
@wmsbill
Slide 40
Slide 40 text
@wmsbill
Function with more params
Slide 41
Slide 41 text
@wmsbill
Function with more params
Slide 42
Slide 42 text
@wmsbill
Awaiting a function
Slide 43
Slide 43 text
@wmsbill
Awaiting a function
Slide 44
Slide 44 text
@wmsbill
Awaiting a function
Slide 45
Slide 45 text
@wmsbill
Awaiting a function
Slide 46
Slide 46 text
@wmsbill
Awaiting a function
Slide 47
Slide 47 text
No content
Slide 48
Slide 48 text
@wmsbill
Smart pipeline
Slide 49
Slide 49 text
@wmsbill
Smart pipeline
Two types bare style and topic style
() or [] are disallowed in bare style
When () or [] is needed, topic style
is used
# token is subject to change
Slide 50
Slide 50 text
@wmsbill
What about curry?
Slide 51
Slide 51 text
No content
Slide 52
Slide 52 text
@wmsbill
F# pipeline proposal
Extends the minimal proposal with
an await step
Await step waits for the resolution of
the previous step
Slide 53
Slide 53 text
@wmsbill
F# pipeline proposal
Slide 54
Slide 54 text
@wmsbill
Slide 55
Slide 55 text
@wmsbill
Partial application
f(…) arity = n;
partialapp(f(…)) arity = m;
m < n
Slide 56
Slide 56 text
@wmsbill
Slide 57
Slide 57 text
@wmsbill
Slide 58
Slide 58 text
@wmsbill
Partial application in ES
Achievable by
Function.prototype.bind
.bind() binds context and
parameters
Slide 59
Slide 59 text
@wmsbill
Slide 60
Slide 60 text
@wmsbill
What about currying?
We can achieve partial application
with curry
Curry ≠ Partial application
Curry returns arity n-1
Slide 61
Slide 61 text
@wmsbill
Slide 62
Slide 62 text
@wmsbill
Partial application with arrow
function
Slide 63
Slide 63 text
No content
Slide 64
Slide 64 text
@wmsbill
Partial application proposal
Creates two new parameters tokens
? For single argument
. . . for multiple parameters (not in the
initial spec anymore)
Slide 65
Slide 65 text
@wmsbill
Partial application syntax
Slide 66
Slide 66 text
@wmsbill
With arbitrary parameter
Slide 67
Slide 67 text
No content
Slide 68
Slide 68 text
@wmsbill
Partial application in template string
Slide 69
Slide 69 text
@wmsbill
Partial application in template string
Slide 70
Slide 70 text
No content
Slide 71
Slide 71 text
@wmsbill
The . . . token
Spread the unbound parameters
Useful when you want to bound first
or last parameter
Slide 72
Slide 72 text
@wmsbill
The . . . token
Slide 73
Slide 73 text
@wmsbill
The . . . token
Slide 74
Slide 74 text
@wmsbill
Partial application + pipeline
Slide 75
Slide 75 text
@wmsbill
Partial application + pipeline
Slide 76
Slide 76 text
@wmsbill
Should I use all of it in production?
These proposal are in very early
stage
The adoption of one, may change
the syntax/semantics of other
Not production ready (yet)