No instantiated objects prototype property

function Human(){
		this.height=180;	
		this.say=function(){
			alert("我在说话");
		}
	}
	var he = new Human();
	alert(Human.prototype);//Object Object
	alert(he.prototype);   //undefined

prototype is the constructor / function that has the properties
JavaScript built-in constructor has the following:
Object, Number The, Boolean, String, Array, RegExp, a Date, Function, Error, Math, JSON, etc.,
wherein the presence of Math and JSON is an object form, no new can be created. When we use var mm = new Math (1234565) ; the time error.
Object, Number, Boolean, String, Array, RegExp, Date, Function, Error prototype is Function.prototype . The prototype Math and JSON object is Object.prototype.

In other words, Javascript, only the above-mentioned object has prototype property, other objects created by the constructor, do not have this property.
1, he is Human an instance object (typeof he = "object") , but not a function, it is not the prototype; Human is an example of a Function and Function is a function of his examples Human also a function (typeof Human = "function"), so they have a prototype. In addition Object Array RegExp, etc. is also a function. Math it is just a new Object (), is not a function.
2, prototype constructors, by default, is a new Object () has added an additional constructor property. So the default is not only a prototype of __proto__.

Guess you like

Origin blog.csdn.net/qq_36711388/article/details/90346459
Recommended