1. Object
A prototype is an attribute of an object, that is, the prototype attribute. Each object has this internal attribute and is also an object.
<Script type = "text/javascript"> Object. prototype. num = 10; alert ("add prototype Object Property:" + Object. num); Object. num = 20; alert ("add Object Property:" + Object. num); </script>
Running result: Add prototype Object Property: 10 Add Object Property: 20
Object. prototype. a = 3.14; alert ("instance of the Object:" + new Object (). a); alert ("attributes of the String object:" + String. a );
Running result: instance of the Object: 3.14 String Object property: 3.14
Analysis: After the Object prototype is extended, the Object is changed to an Object. prototype, that is, all local objects have attributes of this Object. Because all local objects inherit from this Object, String also has the value of attribute.
2. Function object
When a function is executed, the system automatically creates an arguments object attribute for the function object. The arguments object attribute can only be used in the function body and used to manage the actual parameters of the function.
(1) caller attributes
The caller attribute shows the caller of the function. In the following example, function B () is used to call function a and function B is null;
<script type="text/javascript"> var a = new Function("alert('a:'+a.caller)"); function b() { a(); alert('b:'+b.caller); } b();</script>
Running effect:
(2) length attribute
Length is the attribute of the arguments object, indicating the number of parameters passed when the function is called. You can access an actual parameter through an array.
function argc(){ alert(arguments[0]+arguments[1]+arguments[3]);}argc(1,2,3);
The running result is 6.