@@ -423,8 +423,8 @@ To test it in JavaScript:
423423// test.js
424424const addon = require('./build/Release/addon');
425425
426- var obj1 = addon('hello');
427- var obj2 = addon('world');
426+ const obj1 = addon('hello');
427+ const obj2 = addon('world');
428428console.log(obj1.msg, obj2.msg);
429429// Prints: 'hello world'
430430```
@@ -482,7 +482,7 @@ To test:
482482// test.js
483483const addon = require('./build/Release/addon');
484484
485- var fn = addon();
485+ const fn = addon();
486486console.log(fn());
487487// Prints: 'hello world'
488488```
@@ -645,7 +645,7 @@ Test it with:
645645// test.js
646646const addon = require (' ./build/Release/addon' );
647647
648- var obj = new addon.MyObject (10 );
648+ const obj = new addon.MyObject (10 );
649649console .log (obj .plusOne ());
650650// Prints: 11
651651console .log (obj .plusOne ());
@@ -660,9 +660,9 @@ Alternatively, it is possible to use a factory pattern to avoid explicitly
660660creating object instances using the JavaScript ` new ` operator:
661661
662662``` js
663- var obj = addon .createObject ();
663+ const obj = addon .createObject ();
664664// instead of:
665- // var obj = new addon.Object();
665+ // const obj = new addon.Object();
666666```
667667
668668First, the ` createObject() ` method is implemented in ` addon.cc ` :
@@ -840,15 +840,15 @@ Test it with:
840840// test.js
841841const createObject = require (' ./build/Release/addon' );
842842
843- var obj = createObject (10 );
843+ const obj = createObject (10 );
844844console .log (obj .plusOne ());
845845// Prints: 11
846846console .log (obj .plusOne ());
847847// Prints: 12
848848console .log (obj .plusOne ());
849849// Prints: 13
850850
851- var obj2 = createObject (20 );
851+ const obj2 = createObject (20 );
852852console .log (obj2 .plusOne ());
853853// Prints: 21
854854console .log (obj2 .plusOne ());
@@ -1022,9 +1022,9 @@ Test it with:
10221022// test.js
10231023const addon = require('./build/Release/addon');
10241024
1025- var obj1 = addon.createObject(10);
1026- var obj2 = addon.createObject(20);
1027- var result = addon.add(obj1, obj2);
1025+ const obj1 = addon.createObject(10);
1026+ const obj2 = addon.createObject(20);
1027+ const result = addon.add(obj1, obj2);
10281028
10291029console.log(result);
10301030// Prints: 30
0 commit comments