ES3 inside wording
Anonymous function is not take or need to give him the assignment
of the selected part is called the anonymous function
equal sign is called the assignment
let xxx called the statement
so that this place is three grammar, first declare an anonymous function, then declare a variable xxx, finally put this anonymous function assigned to the variable xxx
es6 arrow function
Arrow function can only do an assignment, I do not declare
this is a standard function of the arrow
2 writing, only one parameter
If only one function, you can not write parentheses
calling it to do the test
3 cases of writing, only one sentence in the body of the function
If the body of the function only one sentence, you can not write braces.
We assume that the function body only return p1 + p2 this sentence
then braces can be omitted out. p1 + p2 will default to return in the past.
Only one parameter, and the only function body is only one sentence
Why is there an arrow function
Function there this is the most difficult of
the arrow does not function inside this
What is this? this is the first argument to call
the reason why there will be a function of the arrow, because this is too hard to use.
ES3 inside how to use this
Before talking about this, talk about the parameters
look at the following code, declare the function, f, call the function f, incoming abc, then the value of p1 is abc
fact p1 is the first argument value of
p1 is the argument of the second value
in It builds argument object before executing the function f, which is a function of two parameters f,
Enter this
Without p1 do not p2, printing out this. This is where does this come about?
For better description, this function on a target
assuming two values p1 and p2
Understand python inside slef
Search python class look at the python's class is how to use the
value of 1 is passed p1. So self where they come from it? ?
Back js
The first parameter is actually a function hi this is also an object 1 corresponds p1,2 corresponding p2 is
what this is it? this is actually a front .hi thing here is that this object
is actually the first parameter this object is hidden.
The same is also here this invisible
summarize
this is always the first argument to call
this misuse
Arrow function is to solve this deceptive
such an approach is no problem, is js pits can not be so to write
The wording of the arrow function
Then use the arrow functions can be solved only arrow function parameters, this is not the object
To prove this concept is not a function of the arrow
Most outside of this window is this object
does not object within this arrow function, so print out the most is the outside of the window object
Do this his own name printed.
End