Beruflich Dokumente
Kultur Dokumente
procedure.
20/3: hoisted function can be placed anywhere inside the code while
arrow function cannot. format of arrow function: name of function =
(x,y,. . . ) => function body;, which is an analogue to
(x, y, . . . ) 7→ f (x, y, , . . . ).
x can be string, value, or even an array.
1
var add1 = add.bind(null, 1);
in fact we bind two informations (the object null and the value 1) to the
original add function. When the first parameter, the object null, is bound,
any variable involving “this.property” will be replaced by the correspond-
ing property as listed in the object, at the same time we bind 1 to the first
parameter of add, therefore
add1(x) == add(1,x),
i.e.,
add.bind(obj, 1)(x) = addobj (1, x).
More generally for any array y and any array x0 that we want to bind into
add, we have
add.bind(obj, x0 )(y) = addobj (x0 , y),
depending on how much information we want to bind to the function.
and write
const Tom = {age: 18, sex: "M"};
we have
add.bind(Tom, 1, 2})(100) == 1 + 2 + 100 + 18 == 121.
2
(a true false logical statement)? 2:1 yields 2 when true and 1
when false.
obj instanceof class gives true when obj comes from the class class
(or its subclass(es)).
? array.split? string.split?
? google SEO??