O'Reilly logo

JUNOS Automation Cookbook by Adam Chappell

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

Object-oriented primer for Node.js

In the code that we create, we'll generally be using a simple object-oriented technique of abstracting related data types into encapsulating objects. If this sounds a bit technical, it can be useful to re-acquaint yourself with some of the basic tenets of implementing classic object-oriented programming techniques in JavaScript, which is notable by its prototypal model.

To create a class of object in Javascript, we use a function definition. But when the function is invoked with Javascript's new operator, a new object is created and the function is used as the constructor for the class:

function Thing(name) {   // do construction activities here};var t = new Thing(); 

Instance variables are defined immediately ...

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