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

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -