Last active
June 20, 2021 06:32
-
-
Save ashwinkumar2438/0719c91110f85cf320b6a374c848c4b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Constructor Functions **/ | |
function Person(name){ | |
this.name=name; | |
} | |
Person.isNamed=function(instance){return !!instance.name} | |
var you=new Person(); /** @returns | |
Person { name: undefined | |
__proto__: constructor: ƒ Person{ | |
isNamed: ƒ (instance) | |
} | |
} | |
**/ | |
Person.isNamed(you); //@returns false; | |
/** class Constructor **/ | |
class Person{ | |
constructor(name){ | |
this.name=name; | |
} | |
static isNamed(instance){ | |
return !!instance.name; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment