Вы находитесь на странице: 1из 3

18/3: Memorise the slogan: ACP, Add, Commit, Push for the Gitlab

procedure.

Be sure we are pointing to the working directory (by looking at pwd)


before we go about the ACP procedure.

19/3: for(let ?? in ??) can be used in both object and array

for(let ?? in obj/array) (which gives the index), while for(let ??


of array) (can’t be used in object) gives the “content” being saved, the
name ?? can be whatever we want.

If we have let input; alone, then the input is assigned nothing, we


would have typeof input = ’undefined’. This can be a useful trick if we
want to distinguish whether an input (which we ask user to input by any
means such as prompt(’string’)) exists or not, and base on this we give
different question to user.

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.

? Math is a module? (what is module)

? In a string how to delete character that is not a number? (as demon-


strated in lecture)

parseFloat(·) is an opposite of num.toString(·).

To stop setInterval we need to use clear interval id, i.e., clearInterval(ID),


where ID = setInterval(function(.)).

? difference between let and var?

Consider the following function:


function add(a, b) {
return a + b;
}

and we create another function by using bind:

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),

or to be more precise in mathematics language, we have

add.bind(obj, 1)(x) = add.bind(null, 1)(x) = add1(x) = addobj (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.

For example, define


function add (x,y,z) {
return x+y+z+ this.age;
}

and write
const Tom = {age: 18, sex: "M"};

we have
add.bind(Tom, 1, 2})(100) == 1 + 2 + 100 + 18 == 121.

Useful “method” of array: .IndexOf and .include.

An array can be augmented by .push(). For example, let arr = [];,


then the line arr.push(1); alone (not arr = arr.push(1);!) will assign
arr to [1].

array.pop is an opposite of array.push

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?

? how to use reduce.

? bubble sort (of array) using reduce.

22/3: ? html code: what is attribute?

? google SEO??