What is the significance of this JavaScript code? -
what think doing looking see if object has been instantiated , exists within scope? why need use triple equal sign determine?
function viewmodel(parent) { if (false === (this instanceof viewmodel)) { return new viewmodel(parent); } };
you don't need strict equality comparison there. instanceof
yields true
or false
, entirely sufficient:
if (!(this instanceof viewmodel))
Comments
Post a Comment