Skip to content

Commit cdec174

Browse files
vsemozhetbytaddaleax
authored andcommittedDec 5, 2016
doc: var => const in js code examples of addons.md
PR-URL: #10092 Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Michaël Zasso <targos@protonmail.com>
1 parent 0cab6eb commit cdec174

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed
 

‎doc/api/addons.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,8 @@ To test it in JavaScript:
423423
// test.js
424424
const 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');
428428
console.log(obj1.msg, obj2.msg);
429429
// Prints: 'hello world'
430430
```
@@ -482,7 +482,7 @@ To test:
482482
// test.js
483483
const addon = require('./build/Release/addon');
484484
485-
var fn = addon();
485+
const fn = addon();
486486
console.log(fn());
487487
// Prints: 'hello world'
488488
```
@@ -645,7 +645,7 @@ Test it with:
645645
// test.js
646646
const addon = require('./build/Release/addon');
647647

648-
var obj = new addon.MyObject(10);
648+
const obj = new addon.MyObject(10);
649649
console.log(obj.plusOne());
650650
// Prints: 11
651651
console.log(obj.plusOne());
@@ -660,9 +660,9 @@ Alternatively, it is possible to use a factory pattern to avoid explicitly
660660
creating 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

668668
First, the `createObject()` method is implemented in `addon.cc`:
@@ -840,15 +840,15 @@ Test it with:
840840
// test.js
841841
const createObject = require('./build/Release/addon');
842842

843-
var obj = createObject(10);
843+
const obj = createObject(10);
844844
console.log(obj.plusOne());
845845
// Prints: 11
846846
console.log(obj.plusOne());
847847
// Prints: 12
848848
console.log(obj.plusOne());
849849
// Prints: 13
850850

851-
var obj2 = createObject(20);
851+
const obj2 = createObject(20);
852852
console.log(obj2.plusOne());
853853
// Prints: 21
854854
console.log(obj2.plusOne());
@@ -1022,9 +1022,9 @@ Test it with:
10221022
// test.js
10231023
const 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
10291029
console.log(result);
10301030
// Prints: 30

0 commit comments

Comments
 (0)