Refer: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object
So Object is a constructor function and here I see 2 types of methods defined -
- Static methods - Object.create(), Object.assign() ...
- Instance methods - Object.prototype.hasOwnProperty() ...
I understand how Instance methods are defined and used but no idea about static methods -
function Person() { }
Person.prototype.greetInstance = function () { return 'Hello!' };
let p1 = new Person();
console.log(p1.greetInstance()) // Hello!
console.log(Person.greetStatic()) // where should I define so this works ?? 🤷♂️
Can someone please explain how to define greetStatic() ?
Person.greetStatic = function() { };?