我认为这是在查看该对象是否已经实例化并存在于范围内?为什么我们需要使用三重等号来确定?
function viewmodel(parent) {
if (false === (this instanceof viewmodel)) {
return new viewmodel(parent);
}
};
您不需要在那里进行严格的相等比较。instanceof
产生true
or false
,所以这完全足够:
if (!(this instanceof viewmodel))
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句