Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ const instance = new Derived();
// Derived constructor: 1
```

Because class fields are added using the `[[Define]]` semantic (which is essentially {{jsxref("Global_Objects/Object/defineProperty", "Object.defineProperty()")}}), field declarations in derived classes do not invoke setters in the base class. This behavior differs from using `this.field = ...` in the constructor.
Because class fields are added using the `[[Define]]` semantic (which is essentially {{jsxref("Global_Objects/Object/defineProperty", "Object.defineProperty()")}}), field declarations in derived classes do not invoke setters in the base class. This behavior differs from using `this.field = ` in the constructor.

```js
class Base {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Static methods are often utility functions, such as functions to create or clone
## Syntax

```js
static methodName() { /* ... */ }
static methodName() { /* */ }
static propertyName [= value];

// Class static initialization block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Attempting to delete a plain variable, doesn't work in JavaScript and it throws

var x;

// ...
//

delete x;

Expand All @@ -61,7 +61,7 @@ To free the contents of a variable, you can set it to {{jsxref("null")}}:

var x;

// ...
//

x = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Assigning a value to the same constant name in the same block-scope will throw.
```js example-bad
const COLUMNS = 80;

// ...
//

COLUMNS = 120; // TypeError: invalid assignment to const `COLUMNS'
```
Expand Down Expand Up @@ -73,7 +73,7 @@ global variable with
```js example-good
let columns = 80;

// ...
//

columns = 120;
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The arguments.length property provides the number of arguments actually passed t
In this example we define a function that can add two or more numbers together.

```js
function adder(base /*, n2, ... */) {
function adder(base /*, num1, …, numN */) {
base = Number(base);
for (let i = 1; i < arguments.length; i++) {
base += Number(arguments[i]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ const obj = { // does not create a new scope
},
}

obj.b(); // prints undefined, Window {...} (or the global object)
obj.c(); // prints 10, Object {...}
obj.b(); // prints undefined, Window { /* … */ } (or the global object)
obj.c(); // prints 10, Object { /* … */ }
```

Arrow functions do not have their own `this`. Another example involving
Expand All @@ -215,7 +215,7 @@ const obj = {

Object.defineProperty(obj, 'b', {
get: () => {
console.log(this.a, typeof this.a, this); // undefined 'undefined' Window {...} (or the global object)
console.log(this.a, typeof this.a, this); // undefined 'undefined' Window { /* … */ } (or the global object)
return this.a + 10; // represents global object 'Window', therefore 'this.a' returns 'undefined'
},
});
Expand Down Expand Up @@ -541,7 +541,7 @@ simple(10); // 10

const max = (a, b) => a > b ? a : b;

// Easy array filtering, mapping, ...
// Easy array filtering, mapping, etc.

const arr = [5, 6, 13, 0, 1, 18, 23];

Expand All @@ -557,10 +557,10 @@ const double = arr.map(v => v * 2);
// More concise promise chains
promise
.then(a => {
// ...
//
})
.then(b => {
// ...
//
});

// Parameterless arrow functions that are visually easier to parse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ is passed.
## Syntax

```js
function fnName(param1 = defaultValue1, ..., paramN = defaultValueN) { /* ... */ }
function fnName(param1 = defaultValue1, /* … ,*/ paramN = defaultValueN) { /* */ }
```

## Description
Expand Down
6 changes: 3 additions & 3 deletions files/en-us/web/javascript/reference/functions/get/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ that will be called when that property is looked up.
## Syntax

```js
{get prop() { /* ... */ } }
{get [expression]() { /* ... */ } }
{get prop() { /* */ } }
{get [expression]() { /* */ } }
```

### Parameters
Expand Down Expand Up @@ -61,7 +61,7 @@ Note the following when working with the `get` syntax:

```js example-bad
{
x: ..., get x() { }
x: /* … */, get x() { /* … */ }
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The **rest parameter** syntax allows a function to accept an indefinite number o

```js
function f(a, b, ...theArgs) {
// ...
//
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Note the following when working with the `set` syntax:
- It must not appear in an object literal with another `set` or with a
data entry for the same property.
( `{ set x(v) { }, set x(v) { } }` and
`{ x: ..., set x(v) { } }` are forbidden )
`{ x: , set x(v) { } }` are forbidden )

## Examples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ object or a custom object.
```js
function logIterable(it) {
if (!(Symbol.iterator in it)) {
console.log(it, ' is not an iterable object...');
console.log(it, ' is not an iterable object.');
return;
}

Expand All @@ -113,7 +113,7 @@ logIterable('abc');
// c

logIterable(123);
// 123 is not an iterable object...
// 123 is not an iterable object.
```

## Specifications
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ The **`Array()`** constructor is used to create

```js
// literal constructor
[element0, element1, /* ... ,*/ elementN]
[element0, element1, /* ,*/ elementN]

// construct from elements
new Array(element0, element1, /* ... ,*/ elementN)
new Array(element0, element1, /* ,*/ elementN)

// construct from array length
new Array(arrayLength)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This method does not change the existing arrays, but instead returns a new array
concat()
concat(value0)
concat(value0, value1)
concat(value0, value1, ... , valueN)
concat(value0, value1, /* … ,*/ valueN)
```

### Parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ returns a Boolean value.

```js
// Arrow function
every((element) => { /* ... */ } )
every((element, index) => { /* ... */ } )
every((element, index, array) => { /* ... */ } )
every((element) => { /* */ } )
every((element, index) => { /* */ } )
every((element, index, array) => { /* */ } )

// Callback function
every(callbackFn)
every(callbackFn, thisArg)

// Inline callback function
every(function(element) { /* ... */ })
every(function(element, index) { /* ... */ })
every(function(element, index, array){ /* ... */ })
every(function(element, index, array) { /* ... */ }, thisArg)
every(function(element) { /* */ })
every(function(element, index) { /* */ })
every(function(element, index, array){ /* */ })
every(function(element, index, array) { /* */ }, thisArg)
```

### Parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ The **`filter()`** method creates a [shallow copy](/en-US/docs/Glossary/Shallow_

```js
// Arrow function
filter((element) => { /* ... */ } )
filter((element, index) => { /* ... */ } )
filter((element, index, array) => { /* ... */ } )
filter((element) => { /* */ } )
filter((element, index) => { /* */ } )
filter((element, index, array) => { /* */ } )

// Callback function
filter(callbackFn)
filter(callbackFn, thisArg)

// Inline callback function
filter(function(element) { /* ... */ })
filter(function(element, index) { /* ... */ })
filter(function(element, index, array){ /* ... */ })
filter(function(element, index, array) { /* ... */ }, thisArg)
filter(function(element) { /* */ })
filter(function(element, index) { /* */ })
filter(function(element, index, array){ /* */ })
filter(function(element, index, array) { /* */ }, thisArg)
```

### Parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ If no values satisfy the testing function, {{jsxref("undefined")}} is returned.

```js
// Arrow function
find((element) => { /* ... */ } )
find((element, index) => { /* ... */ } )
find((element, index, array) => { /* ... */ } )
find((element) => { /* */ } )
find((element, index) => { /* */ } )
find((element, index, array) => { /* */ } )

// Callback function
find(callbackFn)
find(callbackFn, thisArg)

// Inline callback function
find(function(element) { /* ... */ })
find(function(element, index) { /* ... */ })
find(function(element, index, array){ /* ... */ })
find(function(element, index, array) { /* ... */ }, thisArg)
find(function(element) { /* */ })
find(function(element, index) { /* */ })
find(function(element, index, array){ /* */ })
find(function(element, index, array) { /* */ }, thisArg)
```

### Parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ See also the {{jsxref("Array.find", "find()")}} method, which returns the first

```js
// Arrow function
findIndex((element) => { /* ... */ } )
findIndex((element, index) => { /* ... */ } )
findIndex((element, index, array) => { /* ... */ } )
findIndex((element) => { /* */ } )
findIndex((element, index) => { /* */ } )
findIndex((element, index, array) => { /* */ } )

// Callback function
findIndex(callbackFn)
findIndex(callbackFn, thisArg)

// Inline callback function
findIndex(function(element) { /* ... */ })
findIndex(function(element, index) { /* ... */ })
findIndex(function(element, index, array){ /* ... */ })
findIndex(function(element, index, array) { /* ... */ }, thisArg)
findIndex(function(element) { /* */ })
findIndex(function(element, index) { /* */ })
findIndex(function(element, index, array){ /* */ })
findIndex(function(element, index, array) { /* */ }, thisArg)
```

### Parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ If you need to find:

```js
// Arrow function
findLast((element) => { /* ... */ } )
findLast((element, index) => { /* ... */ } )
findLast((element, index, array) => { /* ... */ } )
findLast((element) => { /* */ } )
findLast((element, index) => { /* */ } )
findLast((element, index, array) => { /* */ } )

// Callback function
findLast(callbackFn)
findLast(callbackFn, thisArg)

// Inline callback function
findLast(function(element) { /* ... */ })
findLast(function(element, index) { /* ... */ })
findLast(function(element, index, array){ /* ... */ })
findLast(function(element, index, array) { /* ... */ }, thisArg)
findLast(function(element) { /* */ })
findLast(function(element, index) { /* */ })
findLast(function(element, index, array){ /* */ })
findLast(function(element, index, array) { /* */ }, thisArg)
```

### Parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ See also the {{jsxref("Array.findLast()", "findLast()")}} method, which returns

```js
// Arrow function
findLastIndex((element) => { /* ... */ } )
findLastIndex((element, index) => { /* ... */ } )
findLastIndex((element, index, array) => { /* ... */ } )
findLastIndex((element) => { /* */ } )
findLastIndex((element, index) => { /* */ } )
findLastIndex((element, index, array) => { /* */ } )

// Callback function
findLastIndex(callbackFn)
findLastIndex(callbackFn, thisArg)

// Inline callback function
findLastIndex(function(element) { /* ... */ })
findLastIndex(function(element, index) { /* ... */ })
findLastIndex(function(element, index, array){ /* ... */ })
findLastIndex(function(element, index, array) { /* ... */ }, thisArg)
findLastIndex(function(element) { /* */ })
findLastIndex(function(element, index) { /* */ })
findLastIndex(function(element, index, array){ /* */ })
findLastIndex(function(element, index, array) { /* */ }, thisArg)
```

### Parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ The **`flatMap()`** method returns a new array formed by applying a given callba

```js
// Arrow function
flatMap((currentValue) => { /* ... */ } )
flatMap((currentValue, index) => { /* ... */ } )
flatMap((currentValue, index, array) => { /* ... */ } )
flatMap((currentValue) => { /* */ } )
flatMap((currentValue, index) => { /* */ } )
flatMap((currentValue, index, array) => { /* */ } )

// Callback function
flatMap(callbackFn)
flatMap(callbackFn, thisArg)

// Inline callback function
flatMap(function(currentValue) { /* ... */ })
flatMap(function(currentValue, index) { /* ... */ })
flatMap(function(currentValue, index, array){ /* ... */ })
flatMap(function(currentValue, index, array) { /* ... */ }, thisArg)
flatMap(function(currentValue) { /* */ })
flatMap(function(currentValue, index) { /* */ })
flatMap(function(currentValue, index, array){ /* */ })
flatMap(function(currentValue, index, array) { /* */ }, thisArg)
```

### Parameters
Expand Down
Loading