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

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -