Static members

You can add properties in usual way to the function object for making the public static fields and methods.

In ECMA 2015 a static keyword was introduced that allows define public and private static members.

You can access static members via the ClassName., and via this. from other static methods.

function Rectangle(w, h, x=0, y=0){}
Rectangle.descr = "Rectangle is fugure with ...";    
Rectangle.calcArea = function(w,h) {return w*h} 

console.log(`I. descr = ${Rectangle.descr}`); 
console.log(`area(25,3)=${Rectangle.calcArea(25,3)}`);  
class Rectangle2 { // public static descr = "Rectangle is fugure with ..." static descr2 = this.descr static calcArea(w,h){return w*h} static outArea(w,h){console.log(this.calcArea(w,h));} // private static #pvtDescr = "Rectangle is fugure with ..." /* does not supported yet static #pvtCalcArea(w,h){return w*h} */ } console.log(`II. descr = ${Rectangle2.descr}`); console.log(`area(25,3)=${Rectangle2.calcArea(25,3)}`);