Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cdec174

Browse filesBrowse files
vsemozhetbytaddaleax
authored andcommitted
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
Copy full SHA for cdec174

File tree

Expand file treeCollapse file tree

1 file changed

+11
-11
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-11
lines changed
Open diff view settings
Collapse file

‎doc/api/addons.md‎

Copy file name to clipboardExpand all lines: doc/api/addons.md
+11-11Lines changed: 11 additions & 11 deletions
  • Display the source diff
  • Display the rich diff
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.