@@ -98,7 +98,7 @@ in `build/Release/`.
9898You can now use the binary addon in a Node project ` hello.js ` by pointing ` require ` to
9999the recently built ` hello.node ` module:
100100
101- var addon = require('./build/Release/hello');
101+ const addon = require('./build/Release/hello');
102102
103103 console.log(addon.hello()); // 'world'
104104
@@ -175,7 +175,7 @@ function calls and return a result. This is the main and only needed source
175175
176176You can test it with the following JavaScript snippet:
177177
178- var addon = require('./build/Release/addon');
178+ const addon = require('./build/Release/addon');
179179
180180 console.log( 'This should be eight:', addon.add(3,5) );
181181
@@ -215,7 +215,7 @@ adding the function as a property of `exports`.
215215
216216To test it run the following JavaScript snippet:
217217
218- var addon = require('./build/Release/addon');
218+ const addon = require('./build/Release/addon');
219219
220220 addon(function(msg){
221221 console.log(msg); // 'hello world'
@@ -251,10 +251,10 @@ the string passed to `createObject()`:
251251
252252To test it in JavaScript:
253253
254- var addon = require('./build/Release/addon');
254+ const addon = require('./build/Release/addon');
255255
256- var obj1 = addon('hello');
257- var obj2 = addon('world');
256+ const obj1 = addon('hello');
257+ const obj2 = addon('world');
258258 console.log(obj1.msg+' '+obj2.msg); // 'hello world'
259259
260260
@@ -293,9 +293,9 @@ wraps a C++ function:
293293
294294To test:
295295
296- var addon = require('./build/Release/addon');
296+ const addon = require('./build/Release/addon');
297297
298- var fn = addon();
298+ const fn = addon();
299299 console.log(fn()); // 'hello world'
300300
301301
@@ -398,9 +398,9 @@ prototype:
398398
399399Test it with:
400400
401- var addon = require('./build/Release/addon');
401+ const addon = require('./build/Release/addon');
402402
403- var obj = new addon.MyObject(10);
403+ const obj = new addon.MyObject(10);
404404 console.log( obj.plusOne() ); // 11
405405 console.log( obj.plusOne() ); // 12
406406 console.log( obj.plusOne() ); // 13
@@ -411,9 +411,9 @@ Test it with:
411411This is useful when you want to be able to create native objects without
412412explicitly instantiating them with the ` new ` operator in JavaScript, e.g.
413413
414- var obj = addon.createObject();
414+ const obj = addon.createObject();
415415 // instead of:
416- // var obj = new addon.Object();
416+ // const obj = new addon.Object();
417417
418418Let's register our ` createObject ` method in ` addon.cc ` :
419419
@@ -528,14 +528,14 @@ The implementation is similar to the above in `myobject.cc`:
528528
529529Test it with:
530530
531- var createObject = require('./build/Release/addon');
531+ const createObject = require('./build/Release/addon');
532532
533- var obj = createObject(10);
533+ const obj = createObject(10);
534534 console.log( obj.plusOne() ); // 11
535535 console.log( obj.plusOne() ); // 12
536536 console.log( obj.plusOne() ); // 13
537537
538- var obj2 = createObject(20);
538+ const obj2 = createObject(20);
539539 console.log( obj2.plusOne() ); // 21
540540 console.log( obj2.plusOne() ); // 22
541541 console.log( obj2.plusOne() ); // 23
@@ -662,10 +662,10 @@ The implementation of `myobject.cc` is similar as before:
662662
663663Test it with:
664664
665- var addon = require('./build/Release/addon');
665+ const addon = require('./build/Release/addon');
666666
667- var obj1 = addon.createObject(10);
668- var obj2 = addon.createObject(20);
669- var result = addon.add(obj1, obj2);
667+ const obj1 = addon.createObject(10);
668+ const obj2 = addon.createObject(20);
669+ const result = addon.add(obj1, obj2);
670670
671671 console.log(result); // 30
0 commit comments