Note: Function.prototype is the value of the function data type, but the related operation is exactly the same as before->empty/anonymous
The function itself will have its own properties:
Length: The number of formal parameters
Name: Name of "Fn" function
Prototype of the prototype class, the method defined on the prototype is the public method of the current FN class instance.
__proto__ functions as a normal object, pointing to the prototype of the function class.
function is the most complex and important knowledge in the whole JS:
1, a function has a multi-faceted nature:
"Normal function": itself is a normal function, the execution of the time will form a private scope (closure), parameter assignment, pre-interpretation, code execution, after the completion of the stack memory destroyed/not destroyed
"Class": It has its own instance, and there is a prototype called the prototype property, and his instance can point to his own prototype
"Normal Object": Like obj in var obj = {}, it is an ordinary object that can have its own private property as an object, or it can be found by __proto__ Function.prototype
There is no definite relationship between the three of them.
functionFn () {varnum = 500; This. x = 100; } Fn.prototype.getX=function() {Console.log ( This. X)} FN.AAA= 1000; varf =NewFn; F.num//undefinedF.aaa//undefined varres =Fn (); Res//undefinedFn.aaa// +
JS Learning summarizes the three roles of----functions