As a newbie i would like to know that if we do
function square(x) { return x*x; }
and
var s = square;
square(4);
So basically the s
is a new function in which the square function is copied? cause i am confused in this. please help.
so basically the
s
is a new function in which the square function is copied?
No, s
is simply another "name" with which you can refer to the same function.
s === square
will be true
, ie both bindings will refer to the same object.
S is not a new function. It is merely a pointer to the square function. They are both the same.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.