Skip to content

Commit

Permalink
doc: var => const in js code examples of addons.md
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
vsemozhetbyt authored and addaleax committed Dec 5, 2016
1 parent 0cab6eb commit cdec174
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions doc/api/addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,8 @@ To test it in JavaScript:
// test.js
const addon = require('./build/Release/addon');
var obj1 = addon('hello');
var obj2 = addon('world');
const obj1 = addon('hello');
const obj2 = addon('world');
console.log(obj1.msg, obj2.msg);
// Prints: 'hello world'
```
Expand Down Expand Up @@ -482,7 +482,7 @@ To test:
// test.js
const addon = require('./build/Release/addon');
var fn = addon();
const fn = addon();
console.log(fn());
// Prints: 'hello world'
```
Expand Down Expand Up @@ -645,7 +645,7 @@ Test it with:
// test.js
const addon = require('./build/Release/addon');

var obj = new addon.MyObject(10);
const obj = new addon.MyObject(10);
console.log(obj.plusOne());
// Prints: 11
console.log(obj.plusOne());
Expand All @@ -660,9 +660,9 @@ Alternatively, it is possible to use a factory pattern to avoid explicitly
creating object instances using the JavaScript `new` operator:

```js
var obj = addon.createObject();
const obj = addon.createObject();
// instead of:
// var obj = new addon.Object();
// const obj = new addon.Object();
```

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

var obj = createObject(10);
const obj = createObject(10);
console.log(obj.plusOne());
// Prints: 11
console.log(obj.plusOne());
// Prints: 12
console.log(obj.plusOne());
// Prints: 13

var obj2 = createObject(20);
const obj2 = createObject(20);
console.log(obj2.plusOne());
// Prints: 21
console.log(obj2.plusOne());
Expand Down Expand Up @@ -1022,9 +1022,9 @@ Test it with:
// test.js
const addon = require('./build/Release/addon');
var obj1 = addon.createObject(10);
var obj2 = addon.createObject(20);
var result = addon.add(obj1, obj2);
const obj1 = addon.createObject(10);
const obj2 = addon.createObject(20);
const result = addon.add(obj1, obj2);
console.log(result);
// Prints: 30
Expand Down

0 comments on commit cdec174

Please sign in to comment.