@@ -423,8 +423,8 @@ To test it in JavaScript:
423
423
// test.js
424
424
const addon = require('./build/Release/addon');
425
425
426
- var obj1 = addon('hello');
427
- var obj2 = addon('world');
426
+ const obj1 = addon('hello');
427
+ const obj2 = addon('world');
428
428
console.log(obj1.msg, obj2.msg);
429
429
// Prints: 'hello world'
430
430
```
@@ -482,7 +482,7 @@ To test:
482
482
// test.js
483
483
const addon = require('./build/Release/addon');
484
484
485
- var fn = addon();
485
+ const fn = addon();
486
486
console.log(fn());
487
487
// Prints: 'hello world'
488
488
```
@@ -645,7 +645,7 @@ Test it with:
645
645
// test.js
646
646
const addon = require (' ./build/Release/addon' );
647
647
648
- var obj = new addon.MyObject (10 );
648
+ const obj = new addon.MyObject (10 );
649
649
console .log (obj .plusOne ());
650
650
// Prints: 11
651
651
console .log (obj .plusOne ());
@@ -660,9 +660,9 @@ Alternatively, it is possible to use a factory pattern to avoid explicitly
660
660
creating object instances using the JavaScript ` new ` operator:
661
661
662
662
``` js
663
- var obj = addon .createObject ();
663
+ const obj = addon .createObject ();
664
664
// instead of:
665
- // var obj = new addon.Object();
665
+ // const obj = new addon.Object();
666
666
```
667
667
668
668
First, the ` createObject() ` method is implemented in ` addon.cc ` :
@@ -840,15 +840,15 @@ Test it with:
840
840
// test.js
841
841
const createObject = require (' ./build/Release/addon' );
842
842
843
- var obj = createObject (10 );
843
+ const obj = createObject (10 );
844
844
console .log (obj .plusOne ());
845
845
// Prints: 11
846
846
console .log (obj .plusOne ());
847
847
// Prints: 12
848
848
console .log (obj .plusOne ());
849
849
// Prints: 13
850
850
851
- var obj2 = createObject (20 );
851
+ const obj2 = createObject (20 );
852
852
console .log (obj2 .plusOne ());
853
853
// Prints: 21
854
854
console .log (obj2 .plusOne ());
@@ -1022,9 +1022,9 @@ Test it with:
1022
1022
// test.js
1023
1023
const addon = require('./build/Release/addon');
1024
1024
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);
1028
1028
1029
1029
console.log(result);
1030
1030
// Prints: 30
0 commit comments