What specific new operator did it?

New critical examination of profound understanding, whether there is knowledge specializes in front-end, if there is no specializes in people, say for sure that created an object, congratulations interviewer know you are a small rookie to come, this interview is basically not much I hope. Must be of 4 new process steps are very clear, so as to deeply grasp the interviewer's heart!

After a total of four new stages

1. Create an empty object

varobj=new Object();


2, disposed prototype chain

obj.__proto__= Func.prototype;


3, so that in this point Func obj, and execution of the function body Func.

var result =Func.call(obj);


4, return type Func is determined:

If it is a value type, returns obj. If it is a reference type, and then return the referenced object type.

if (typeof(result) == "object"){
func=result;
}
else{
func=obj;;
}


Source: CSDN
Original: https: //blog.csdn.net/lxcao/article/details/52792466
Copyright: This article is a blogger original article, reproduced, please attach Bowen link!

Guess you like

Origin www.cnblogs.com/calvin-dong/p/11228933.html