Apply, call, bind, декоратор

Call:

1
func.call(context, arg1, arg2, ...)

Apply:

1
func.apply(context, [arg1, arg2, ...])

Bind:

1
2
3
let fn = func.bind(context, arg1, arg2, ...) fn()

Декоратор:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
let fn = (x) => { return x} const decorator = (fn) => { const cache = new Map() return (x) => { if(map.has(x)){ return map.get(x) } const res = fn(x) map.set(x, res) return res }} fn = decorator(fn)