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
5 changes: 5 additions & 0 deletions files/en-us/_redirects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15528,9 +15528,14 @@
/en-US/docs/Web/JavaScript/Reference/Symbols /en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol
/en-US/docs/Web/JavaScript/Reference/arrow_functions /en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
/en-US/docs/Web/JavaScript/Reference/default_parameters /en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters
/en-US/docs/Web/JavaScript/Reference/delete /en-US/docs/Web/JavaScript/Reference/Operators/delete
/en-US/docs/Web/JavaScript/Reference/eval /en-US/docs/Web/JavaScript/Reference/Global_Objects/eval
/en-US/docs/Web/JavaScript/Reference/instanceof /en-US/docs/Web/JavaScript/Reference/Operators/instanceof
/en-US/docs/Web/JavaScript/Reference/new /en-US/docs/Web/JavaScript/Reference/Operators/new
/en-US/docs/Web/JavaScript/Reference/null /en-US/docs/Web/JavaScript/Reference/Operators/null
/en-US/docs/Web/JavaScript/Reference/rest_parameters /en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters
/en-US/docs/Web/JavaScript/Reference/template_strings /en-US/docs/Web/JavaScript/Reference/Template_literals
/en-US/docs/Web/JavaScript/Reference/this /en-US/docs/Web/JavaScript/Reference/Operators/this
/en-US/docs/Web/JavaScript/Same_origin_policy_for_JavaScript /en-US/docs/Web/Security/Defenses/Same-origin_policy
/en-US/docs/Web/JavaScript/Shells /en-US/docs/Web/JavaScript/Reference/JavaScript_technologies_overview
/en-US/docs/Web/JavaScript/The_performance_hazards_of__[[Prototype]]_mutation /en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/glossary/binding/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ page-type: glossary-definition
sidebar: glossarysidebar
---

In programming, a **binding** is an association of an {{glossary("identifier")}} with a value. Not all bindings are {{glossary("variable", "variables")}} — for example, function {{glossary("parameter", "parameters")}} and the binding created by the {{jsxref("Statements/try...catch", "catch (e)")}} block are not "variables" in the strict sense. In addition, some bindings are implicitly created by the language — for example, {{jsxref("Operators/this", "this")}} and [`new.target`](/en-US/docs/Web/JavaScript/Reference/Operators/new.target) in JavaScript.
In programming, a **binding** is an association of an {{glossary("identifier")}} with a value. Not all bindings are {{glossary("variable", "variables")}} — for example, function {{glossary("parameter", "parameters")}} and the binding created by the {{jsxref("Statements/try...catch", "catch (e)")}} block are not "variables" in the strict sense. In addition, some bindings are implicitly created by the language — for example, {{jsxref("this")}} and [`new.target`](/en-US/docs/Web/JavaScript/Reference/Operators/new.target) in JavaScript.

A binding is {{glossary("mutable")}} if it can be re-assigned, and {{glossary("immutable")}} otherwise; this does _not_ mean that the value it holds is immutable.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ frankie.introduceSelf();
// "Hi! I'm Frankie."
```

This works fine but is a bit long-winded: we have to create an empty object, initialize it, and return it. A better way is to use a **constructor**. A constructor is just a function called using the {{jsxref("operators/new", "new")}} keyword. When you call a constructor, it will:
This works fine but is a bit long-winded: we have to create an empty object, initialize it, and return it. A better way is to use a **constructor**. A constructor is just a function called using the {{jsxref("new")}} keyword. When you call a constructor, it will:

- create a new object
- bind `this` to the new object, so you can refer to `this` in your constructor code
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/mozilla/firefox/releases/38/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Highlights:
- Duplicated parameter name is no longer allowed when rest-parameter is present ([Firefox bug 1096376](https://bugzil.la/1096376)).
- Duplicated parameter name is no longer allowed in arrow functions ([Firefox bug 1096377](https://bugzil.la/1096377)).
- Duplicated parameter name is no longer allowed in concise method definitions ([Firefox bug 1096378](https://bugzil.la/1096378)).
- Warning is shown when {{jsxref("Map")}}/{{jsxref("Set")}}/{{jsxref("WeakMap")}} constructor is called without {{jsxref("Operators/new", "new")}} ([Firefox bug 1108930](https://bugzil.la/1108930)).
- Warning is shown when {{jsxref("Map")}}/{{jsxref("Set")}}/{{jsxref("WeakMap")}} constructor is called without {{jsxref("new")}} ([Firefox bug 1108930](https://bugzil.la/1108930)).
- The {{jsxref("WeakMap.get", "get")}}, {{jsxref("WeakMap.has", "has")}}, and {{jsxref("WeakMap.delete", "delete")}} methods of {{jsxref("WeakMap")}} objects no longer throw when the `key` parameter is not an object ([Firefox bug 1127827](https://bugzil.la/1127827)).
- The optional and non-standard second `fallback` parameter for {{jsxref("WeakMap.prototype.get()")}} has been removed ([Firefox bug 1127827](https://bugzil.la/1127827)).
- When defining a [generator method](/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions), `set` and `get` are no longer invalid names ([Firefox bug 1073809](https://bugzil.la/1073809)).
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/mozilla/firefox/releases/40/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ _No change._
- Unreachable code after {{jsxref("Statements/return", "return")}} statement (including unreachable expression after {{jsxref("Statements/return", "semicolon-less return statements", "#Automatic_semicolon_insertion", 1)}}) will now show a warning in the console ([Firefox bug 1005110](https://bugzil.la/1005110), [Firefox bug 1151931](https://bugzil.la/1151931)).
- {{jsxref("Symbol.match")}} has been added ([Firefox bug 1054755](https://bugzil.la/1054755)).
- Passing an object which has a property named {{jsxref("Symbol.match")}} with a {{Glossary("truthy")}} value to {{jsxref("String.prototype.startsWith")}}, {{jsxref("String.prototype.endsWith")}}, and `String.prototype.contains` now throws a {{jsxref("TypeError")}} ([Firefox bug 1054755](https://bugzil.la/1054755)).
- {{jsxref("RegExp")}} function returns pattern itself if called without {{jsxref("Operators/new", "new")}} and pattern object has a property named {{jsxref("Symbol.match")}} with a {{Glossary("truthy")}} value, and the pattern object's `constructor` property equals to {{jsxref("RegExp")}} function. ([Firefox bug 1147817](https://bugzil.la/1147817)).
- {{jsxref("RegExp")}} function returns pattern itself if called without {{jsxref("new")}} and pattern object has a property named {{jsxref("Symbol.match")}} with a {{Glossary("truthy")}} value, and the pattern object's `constructor` property equals to {{jsxref("RegExp")}} function. ([Firefox bug 1147817](https://bugzil.la/1147817)).
- Support for the non-standard JS1.7 destructuring for-in has been dropped ([Firefox bug 1083498](https://bugzil.la/1083498)).
- [Non-standard initializer expressions](/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_for-in_initializer) in [`for...in`](/en-US/docs/Web/JavaScript/Reference/Statements/for...in) loops are now ignored and will present a warning in the console. ([Firefox bug 748550](https://bugzil.la/748550) and [Firefox bug 1164741](https://bugzil.la/1164741)).
- [`\u{xxxxxx}`](/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#unicode_code_point_escapes) Unicode code point escapes have been added ([Firefox bug 320500](https://bugzil.la/320500)).
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/mozilla/firefox/releases/44/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Highlights:
#### Changes

- The [`let`](/en-US/docs/Web/JavaScript/Reference/Statements/let) and [`const`](/en-US/docs/Web/JavaScript/Reference/Statements/const) bindings in the global level have been made compliant with ES2015 semantics. See [Firefox bug 589199](https://bugzil.la/589199) and the blog post ["Breaking changes in let and const in Firefox Nightly 44"](https://blog.mozilla.org/addons/2015/10/14/breaking-changes-let-const-firefox-nightly-44/). In addition, `let` is now available to default Web JavaScript (strict and non-strict) and does not require a version opt-in anymore ([Firefox bug 932517](https://bugzil.la/932517)).
- If [typed arrays'](/en-US/docs/Web/JavaScript/Guide/Typed_arrays) (like {{jsxref("Int8Array", "Int8Array")}}) and {{jsxref("ArrayBuffer", "ArrayBuffer")}}) constructors are called as a function without the {{jsxref("Operators/new", "new")}} operator, a {{jsxref("TypeError")}} is now thrown as per the ES2015 specification ([Firefox bug 980945](https://bugzil.la/980945), [Firefox bug 1214936](https://bugzil.la/1214936)).
- If [typed arrays'](/en-US/docs/Web/JavaScript/Guide/Typed_arrays) (like {{jsxref("Int8Array", "Int8Array")}}) and {{jsxref("ArrayBuffer", "ArrayBuffer")}}) constructors are called as a function without the {{jsxref("new")}} operator, a {{jsxref("TypeError")}} is now thrown as per the ES2015 specification ([Firefox bug 980945](https://bugzil.la/980945), [Firefox bug 1214936](https://bugzil.la/1214936)).
- The {{jsxref("RegExp")}} sticky flag now follows the ES2015 standard for [anchored sticky regular expressions](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky#anchored_sticky_flag) ([Firefox bug 773687](https://bugzil.la/773687)).
- The JavaScript shell (SpiderMonkey's REPL) now defaults to the default, Web-compatible JS version (and not JS1.7+ anymore) ([Firefox bug 1192329](https://bugzil.la/1192329)).

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/domtokenlist/foreach/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ forEach(callback, thisArg)
- : The array that `forEach()` is being applied to.

- `thisArg` {{Optional_inline}}
- : The value to use as {{jsxref("Operators/this", "this")}} when executing `callback`.
- : The value to use as {{jsxref("this")}} when executing `callback`.

### Return value

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/eventtarget/addeventlistener/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ It is often desirable to reference the element on which the event handler was fi
such as when using a generic handler for a set of similar elements.

When attaching a handler function to an element using `addEventListener()`,
the value of {{jsxref("Operators/this","this")}} inside the handler will be a reference to
the value of {{jsxref("this")}} inside the handler will be a reference to
the element. It will be the same as the value of the `currentTarget` property of
the event argument that is passed to the handler.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The `presentationTime` is optional — some browsers may choose always to return

## Value

A {{domxref("DOMHighResTimeStamp")}} or {{jsxref("Operators/null", "null")}} if the value is not exposed.
A {{domxref("DOMHighResTimeStamp")}} or {{jsxref("null")}} if the value is not exposed.

## Examples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The `presentationTime` is optional — some browsers may choose always to return

## Value

A {{domxref("DOMHighResTimeStamp")}} or {{jsxref("Operators/null", "null")}} if the value is not exposed.
A {{domxref("DOMHighResTimeStamp")}} or {{jsxref("null")}} if the value is not exposed.

## Examples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The `presentationTime` is optional — some browsers may choose always to return

## Value

A {{domxref("DOMHighResTimeStamp")}} or {{jsxref("Operators/null", "null")}} if the value is not exposed.
A {{domxref("DOMHighResTimeStamp")}} or {{jsxref("null")}} if the value is not exposed.

## Examples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The `presentationTime` is optional — some browsers may choose always to return

## Value

A {{domxref("DOMHighResTimeStamp")}} or {{jsxref("Operators/null", "null")}} if the value is not exposed.
A {{domxref("DOMHighResTimeStamp")}} or {{jsxref("null")}} if the value is not exposed.

## Examples

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/windowclient/navigate/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ navigate(url)

### Return value

A {{jsxref("Promise")}} that resolves to the existing {{domxref("WindowClient")}} if the URL is from the same origin as the service worker, or {{jsxref("Operators/null", "null")}} otherwise.
A {{jsxref("Promise")}} that resolves to the existing {{domxref("WindowClient")}} if the URL is from the same origin as the service worker, or {{jsxref("null")}} otherwise.

## Specifications

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/javascript/guide/meta_programming/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ The following table summarizes the available traps available to `Proxy` objects.
{{jsxref("Proxy/Proxy/getPrototypeOf", "handler.getPrototypeOf()")}}
</td>
<td>
{{jsxref("Object.getPrototypeOf()")}}<br />{{jsxref("Reflect.getPrototypeOf()")}}<br />{{jsxref("Object/proto", "__proto__")}}<br />{{jsxref("Object.prototype.isPrototypeOf()")}}<br />{{jsxref("Operators/instanceof", "instanceof")}}
{{jsxref("Object.getPrototypeOf()")}}<br />{{jsxref("Reflect.getPrototypeOf()")}}<br />{{jsxref("Object/proto", "__proto__")}}<br />{{jsxref("Object.prototype.isPrototypeOf()")}}<br />{{jsxref("instanceof")}}
</td>
</tr>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/javascript/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Browse the complete [JavaScript reference](/en-US/docs/Web/JavaScript/Reference)
- [Standard objects](/en-US/docs/Web/JavaScript/Reference/Global_Objects)
- : Get to know standard built-in objects: {{jsxref("Array")}}, {{jsxref("Boolean")}}, {{jsxref("Error")}}, {{jsxref("Function")}}, {{jsxref("JSON")}}, {{jsxref("Math")}}, {{jsxref("Number")}}, {{jsxref("Object")}}, {{jsxref("RegExp")}}, {{jsxref("String")}}, {{jsxref("Map")}}, {{jsxref("Set")}}, {{jsxref("WeakMap")}}, {{jsxref("WeakSet")}}, and others.
- [Expressions and operators](/en-US/docs/Web/JavaScript/Reference/Operators)
- : Learn more about the behavior of JavaScript's operators {{jsxref("Operators/instanceof", "instanceof")}}, {{jsxref("Operators/typeof", "typeof")}}, {{jsxref("Operators/new", "new")}}, {{jsxref("Operators/this", "this")}}, the [operator precedence](/en-US/docs/Web/JavaScript/Reference/Operators/Operator_precedence), and more.
- : Learn more about the behavior of JavaScript's operators {{jsxref("instanceof")}}, {{jsxref("Operators/typeof", "typeof")}}, {{jsxref("new")}}, {{jsxref("this")}}, the [operator precedence](/en-US/docs/Web/JavaScript/Reference/Operators/Operator_precedence), and more.
- [Statements and declarations](/en-US/docs/Web/JavaScript/Reference/Statements)
- : Learn how {{jsxref("Statements/do...while", "do-while")}}, {{jsxref("Statements/for...in", "for-in")}}, {{jsxref("Statements/for...of", "for-of")}}, {{jsxref("Statements/try...catch", "try-catch")}}, {{jsxref("Statements/let", "let")}}, {{jsxref("Statements/var", "var")}}, {{jsxref("Statements/const", "const")}}, {{jsxref("Statements/if...else", "if-else")}}, {{jsxref("Statements/switch", "switch")}}, and more JavaScript statements and keywords work.
- [Functions](/en-US/docs/Web/JavaScript/Reference/Functions)
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/javascript/reference/classes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ For how instances are created, see the {{jsxref("Classes/constructor", "construc

### Binding this with instance and static methods

When a static or instance method is called without a value for {{jsxref("Operators/this", "this")}}, such as by assigning the method to a variable and then calling it, the `this` value will be `undefined` inside the method. This behavior is the same even if the [`"use strict"`](/en-US/docs/Web/JavaScript/Reference/Strict_mode) directive isn't present, because code within the `class` body is always executed in strict mode.
When a static or instance method is called without a value for {{jsxref("this")}}, such as by assigning the method to a variable and then calling it, the `this` value will be `undefined` inside the method. This behavior is the same even if the [`"use strict"`](/en-US/docs/Web/JavaScript/Reference/Strict_mode) directive isn't present, because code within the `class` body is always executed in strict mode.

```js
class Animal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ StaticMethodCall.anotherStaticMethod();

### Calling static members from a class constructor and other methods

Static members are not directly accessible using the {{jsxref("Operators/this", "this")}} keyword from
Static members are not directly accessible using the {{jsxref("this")}} keyword from
non-static methods. You need to call them using the class name:
`CLASSNAME.STATIC_METHOD_NAME()` /
`CLASSNAME.STATIC_PROPERTY_NAME` or by calling the method as a property of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ page-type: javascript-error
sidebar: jssidebar
---

The JavaScript exception "new keyword cannot be used with an optional chain" occurs when the constructor of a {{jsxref("Operators/new", "new")}} expression is an [optional chain](/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining), or if there's an optional chain between the constructor and the parenthesized list of arguments.
The JavaScript exception "new keyword cannot be used with an optional chain" occurs when the constructor of a {{jsxref("new")}} expression is an [optional chain](/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining), or if there's an optional chain between the constructor and the parenthesized list of arguments.

## Message

Expand Down Expand Up @@ -62,6 +62,6 @@ Note that there's no needs to use `?.` on the `new` expression itself: `new a()?

## See also

- {{jsxref("Operators/new", "new")}}
- {{jsxref("new")}}
- [Optional chaining (`?.`)](/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining)
- [Original discussion on whether "optional new" should be allowed](https://github.com/tc39/proposal-optional-chaining/issues/22)
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ SyntaxError: super is not valid in this context. (Safari)

## What went wrong?

The `super()` call is used to invoke the base constructor of a derived class, so the base class can initialize the {{jsxref("Operators/this", "this")}} object. Using it anywhere else doesn't make sense.
The `super()` call is used to invoke the base constructor of a derived class, so the base class can initialize the {{jsxref("this")}} object. Using it anywhere else doesn't make sense.

`super()` can also be defined in an arrow function that's nested within the constructor. However, it cannot be defined in any other kind of function.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ page-type: javascript-error
sidebar: jssidebar
---

The JavaScript exception "calling a builtin X constructor without new is forbidden" occurs when you try to call a builtin constructor without using the {{jsxref("Operators/new", "new")}} keyword. All modern constructors, such as {{jsxref("Promise")}} and {{jsxref("Map")}}, must be called with `new`.
The JavaScript exception "calling a builtin X constructor without new is forbidden" occurs when you try to call a builtin constructor without using the {{jsxref("new")}} keyword. All modern constructors, such as {{jsxref("Promise")}} and {{jsxref("Map")}}, must be called with `new`.

## Message

Expand Down Expand Up @@ -52,4 +52,4 @@ const m = new Map();

## See also

- {{jsxref("Operators/new", "new")}}
- {{jsxref("new")}}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ page-type: javascript-error
sidebar: jssidebar
---

The JavaScript exception "class constructors must be invoked with 'new'" occurs when a [class constructor](/en-US/docs/Web/JavaScript/Reference/Classes) is called without the {{jsxref("Operators/new", "new")}} keyword. All class constructors must be called with `new`.
The JavaScript exception "class constructors must be invoked with 'new'" occurs when a [class constructor](/en-US/docs/Web/JavaScript/Reference/Classes) is called without the {{jsxref("new")}} keyword. All class constructors must be called with `new`.

## Message

Expand Down Expand Up @@ -47,4 +47,4 @@ new X();
## See also

- [Classes](/en-US/docs/Web/JavaScript/Reference/Classes)
- {{jsxref("Operators/new", "new")}}
- {{jsxref("new")}}
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ new Derived(); // { x: 1 }

- [Classes](/en-US/docs/Web/JavaScript/Reference/Classes)
- {{jsxref("Classes/extends", "extends")}}
- {{jsxref("Operators/new", "new")}}
- {{jsxref("new")}}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ page-type: javascript-error
sidebar: jssidebar
---

The JavaScript exception "must call super constructor before using 'this' in derived class constructor" occurs when the {{jsxref("Operators/super", "super()")}} is not called for a given derived class constructor, and the derived constructor tries to access the value of {{jsxref("Operators/this", "this")}}, or the derived constructor has already returned and the return value is not an object.
The JavaScript exception "must call super constructor before using 'this' in derived class constructor" occurs when the {{jsxref("Operators/super", "super()")}} is not called for a given derived class constructor, and the derived constructor tries to access the value of {{jsxref("this")}}, or the derived constructor has already returned and the return value is not an object.

## Message

Expand Down
Loading