1. Object object
Prototype is an attribute of the object, that is, prototype attribute. Each object has this internal attribute, and it is also an object.
<script type="text/javascript"> Object.prototype.num= 10; alert("添加原型对象属性:"+ Object.num); Object.num = 20; alert("添加对象属性:"+Object.num);</script>
Run results: Add prototype object attributes: 10 Add object attributes: 20
Object.prototype.a = 3.14;alert("Object对象的实例:"+ new Object().a);alert("String对象的属性:"+ String.a);
Run results: Instance of Object object: 3.14 Attributes of String object: 3.14
Analysis: When the prototype of Object is extended, it is equivalent to the object becoming Object.prototype, that is, all local objects have this The properties of the object, because all local objects inherit the Object object, String also has the value of attribute a.
2. Function object
When a function is executed, the system will automatically create an arguments object attribute for the function object, arguments Object attributes can only be used in function bodies and are used to manage the actual parameters of the function.
(1) caller attribute
The caller attribute shows the caller of the function, so in the following example, the caller of function a is function b(); the caller of 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: , an actual parameter can be accessed through an array.
The running result is 6
function argc(){ alert(arguments[0]+arguments[1]+arguments[3]);}argc(1,2,3);