Skip to content

Instantly share code, notes, and snippets.

@ashwinkumar2438
Last active June 20, 2021 06:32
Show Gist options
  • Save ashwinkumar2438/0719c91110f85cf320b6a374c848c4b7 to your computer and use it in GitHub Desktop.
Save ashwinkumar2438/0719c91110f85cf320b6a374c848c4b7 to your computer and use it in GitHub Desktop.
/** 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