O'Reilly logo

Cross-platform Desktop Application Development: Electron, Node, NW.js, and React by Dmitry Sheiko

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Classes

JavaScript implies a prototype-based, object-oriented programming style. It differs from class-based OOP that is used in other popular programming languages, such as C++, C#, Objective-C, Java, and PHP. This used to confuse newcomer developers. ES2015 offers a syntactic sugar over the prototype, which looks pretty much like canonical classes:

 class Machine {     constructor( name ){    this.name = name;   } } class Robot extends Machine {   constructor( name ){    super( name );   }   move( direction = "left" ){    console.log( this.name + " moving ", Robot.normalizeDirection( direction ) );   }   static normalizeDirection( direction ) {           return direction.toLowerCase();   } }  const robot = new Robot( "R2D2" ); robot.move(); robot.move( "RIGHT" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required