Skip to content

Commit

Permalink
Make jsxref macro invocations terser (#29081)
Browse files Browse the repository at this point in the history
* Make jsxref macro invocations terser

* Revert supportedLocalesOf

* Revert eval
  • Loading branch information
Josh-Cena committed Sep 25, 2023
1 parent 0375c6e commit fb85334
Show file tree
Hide file tree
Showing 127 changed files with 276 additions and 310 deletions.
27 changes: 0 additions & 27 deletions files/en-us/web/javascript/guide/functions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -699,31 +699,4 @@ function Person() {
const p = new Person();
```

## Predefined functions

JavaScript has several top-level, built-in functions:

- {{jsxref("Global_Objects/eval", "eval()")}}
- : The **`eval()`** method evaluates JavaScript code represented as a string.
- {{jsxref("Global_Objects/isFinite", "isFinite()")}}
- : The global **`isFinite()`** function determines whether the passed value is a finite number. If needed, the parameter is first converted to a number.
- {{jsxref("Global_Objects/isNaN", "isNaN()")}}
- : The **`isNaN()`** function determines whether a value is {{jsxref("Global_Objects/NaN", "NaN")}} or not. Note: coercion inside the `isNaN` function has [interesting](/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN#description) rules; you may alternatively want to use {{jsxref("Number.isNaN()")}} to determine if the value is Not-A-Number.
- {{jsxref("Global_Objects/parseFloat", "parseFloat()")}}
- : The **`parseFloat()`** function parses a string argument and returns a floating point number.
- {{jsxref("Global_Objects/parseInt", "parseInt()")}}
- : The **`parseInt()`** function parses a string argument and returns an integer of the specified radix (the base in mathematical numeral systems).
- {{jsxref("Global_Objects/decodeURI", "decodeURI()")}}
- : The **`decodeURI()`** function decodes a Uniform Resource Identifier (URI) previously created by {{jsxref("Global_Objects/encodeURI", "encodeURI")}} or by a similar routine.
- {{jsxref("Global_Objects/decodeURIComponent", "decodeURIComponent()")}}
- : The **`decodeURIComponent()`** method decodes a Uniform Resource Identifier (URI) component previously created by {{jsxref("Global_Objects/encodeURIComponent", "encodeURIComponent")}} or by a similar routine.
- {{jsxref("Global_Objects/encodeURI", "encodeURI()")}}
- : The **`encodeURI()`** method encodes a Uniform Resource Identifier (URI) by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two "surrogate" characters).
- {{jsxref("Global_Objects/encodeURIComponent", "encodeURIComponent()")}}
- : The **`encodeURIComponent()`** method encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two "surrogate" characters).
- {{jsxref("Global_Objects/escape", "escape()")}} {{deprecated_inline}}
- : The **`escape()`** method computes a new string in which certain characters have been replaced by a hexadecimal escape sequence. It's deprecated and you should use {{jsxref("Global_Objects/encodeURI", "encodeURI()")}} or {{jsxref("Global_Objects/encodeURIComponent", "encodeURIComponent()")}} instead.
- {{jsxref("Global_Objects/unescape", "unescape()")}} {{deprecated_inline}}
- : The **`unescape()`** method computes a new string in which hexadecimal escape sequences are replaced with the character that it represents. The escape sequences might be introduced by a function like {{jsxref("Global_Objects/escape", "escape()")}}. It's deprecated and you should use {{jsxref("Global_Objects/decodeURI", "decodeURI()")}} or {{jsxref("Global_Objects/decodeURIComponent", "decodeURIComponent()")}} instead.

{{PreviousNext("Web/JavaScript/Guide/Loops_and_iteration", "Web/JavaScript/Guide/Expressions_and_operators")}}
4 changes: 2 additions & 2 deletions files/en-us/web/javascript/guide/grammar_and_types/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ With all other operators, JavaScript does _not_ convert numeric values to string

In the case that a value representing a number is in memory as a string, there are methods for conversion.

- {{jsxref("parseInt", "parseInt()")}}
- {{jsxref("parseFloat", "parseFloat()")}}
- {{jsxref("parseInt()")}}
- {{jsxref("parseFloat()")}}

`parseInt` only returns whole numbers, so its use is diminished for decimals.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Once created, an iterator object can be iterated explicitly by repeatedly callin

The most common iterator in JavaScript is the Array iterator, which returns each value in the associated array in sequence.

While it is easy to imagine that all iterators could be expressed as arrays, this is not true. Arrays must be allocated in their entirety, but iterators are consumed only as necessary. Because of this, iterators can express sequences of unlimited size, such as the range of integers between `0` and {{jsxref("Global_Objects/Infinity", "Infinity")}}.
While it is easy to imagine that all iterators could be expressed as arrays, this is not true. Arrays must be allocated in their entirety, but iterators are consumed only as necessary. Because of this, iterators can express sequences of unlimited size, such as the range of integers between `0` and {{jsxref("Infinity")}}.

Here is an example which can do just that. It allows creation of a simple range iterator which defines a sequence of integers from `start` (inclusive) to `end` (exclusive) spaced `step` apart. Its final return value is the size of the sequence it created, tracked by the variable `iterationCount`.

Expand Down
26 changes: 13 additions & 13 deletions files/en-us/web/javascript/guide/meta_programming/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ The following table summarizes the available traps available to `Proxy` objects.
<tbody>
<tr>
<td>
{{jsxref("Global_Objects/Proxy/Proxy/getPrototypeOf", "handler.getPrototypeOf()")}}
{{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")}}
Expand All @@ -80,7 +80,7 @@ The following table summarizes the available traps available to `Proxy` objects.
</tr>
<tr>
<td>
{{jsxref("Global_Objects/Proxy/Proxy/setPrototypeOf", "handler.setPrototypeOf()")}}
{{jsxref("Proxy/Proxy/setPrototypeOf", "handler.setPrototypeOf()")}}
</td>
<td>
{{jsxref("Object.setPrototypeOf()")}}<br />{{jsxref("Reflect.setPrototypeOf()")}}
Expand All @@ -93,7 +93,7 @@ The following table summarizes the available traps available to `Proxy` objects.
</tr>
<tr>
<td>
{{jsxref("Global_Objects/Proxy/Proxy/isExtensible", "handler.isExtensible()")}}
{{jsxref("Proxy/Proxy/isExtensible", "handler.isExtensible()")}}
</td>
<td>
{{jsxref("Object.isExtensible()")}}<br />{{jsxref("Reflect.isExtensible()")}}
Expand All @@ -105,7 +105,7 @@ The following table summarizes the available traps available to `Proxy` objects.
</tr>
<tr>
<td>
{{jsxref("Global_Objects/Proxy/Proxy/preventExtensions", "handler.preventExtensions()")}}
{{jsxref("Proxy/Proxy/preventExtensions", "handler.preventExtensions()")}}
</td>
<td>
{{jsxref("Object.preventExtensions()")}}<br />{{jsxref("Reflect.preventExtensions()")}}
Expand All @@ -119,7 +119,7 @@ The following table summarizes the available traps available to `Proxy` objects.
</tr>
<tr>
<td>
{{jsxref("Global_Objects/Proxy/Proxy/getOwnPropertyDescriptor", "handler.getOwnPropertyDescriptor()")}}
{{jsxref("Proxy/Proxy/getOwnPropertyDescriptor", "handler.getOwnPropertyDescriptor()")}}
</td>
<td>
{{jsxref("Object.getOwnPropertyDescriptor()")}}<br />{{jsxref("Reflect.getOwnPropertyDescriptor()")}}
Expand Down Expand Up @@ -163,7 +163,7 @@ The following table summarizes the available traps available to `Proxy` objects.
</tr>
<tr>
<td>
{{jsxref("Global_Objects/Proxy/Proxy/defineProperty", "handler.defineProperty()")}}
{{jsxref("Proxy/Proxy/defineProperty", "handler.defineProperty()")}}
</td>
<td>
{{jsxref("Object.defineProperty()")}}<br />{{jsxref("Reflect.defineProperty()")}}
Expand Down Expand Up @@ -202,7 +202,7 @@ The following table summarizes the available traps available to `Proxy` objects.
</tr>
<tr>
<td>
{{jsxref("Global_Objects/Proxy/Proxy/has", "handler.has()")}}
{{jsxref("Proxy/Proxy/has", "handler.has()")}}
</td>
<td>
<dl>
Expand Down Expand Up @@ -232,7 +232,7 @@ The following table summarizes the available traps available to `Proxy` objects.
</tr>
<tr>
<td>
{{jsxref("Global_Objects/Proxy/Proxy/get", "handler.get()")}}
{{jsxref("Proxy/Proxy/get", "handler.get()")}}
</td>
<td>
<dl>
Expand Down Expand Up @@ -269,7 +269,7 @@ The following table summarizes the available traps available to `Proxy` objects.
</tr>
<tr>
<td>
{{jsxref("Global_Objects/Proxy/Proxy/set", "handler.set()")}}
{{jsxref("Proxy/Proxy/set", "handler.set()")}}
</td>
<td>
<dl>
Expand Down Expand Up @@ -311,7 +311,7 @@ The following table summarizes the available traps available to `Proxy` objects.
</tr>
<tr>
<td>
{{jsxref("Global_Objects/Proxy/Proxy/deleteProperty", "handler.deleteProperty()")}}
{{jsxref("Proxy/Proxy/deleteProperty", "handler.deleteProperty()")}}
</td>
<td>
<dl>
Expand All @@ -331,7 +331,7 @@ The following table summarizes the available traps available to `Proxy` objects.
</tr>
<tr>
<td>
{{jsxref("Global_Objects/Proxy/Proxy/ownKeys", "handler.ownKeys()")}}
{{jsxref("Proxy/Proxy/ownKeys", "handler.ownKeys()")}}
</td>
<td>
{{jsxref("Object.getOwnPropertyNames()")}}<br />{{jsxref("Object.getOwnPropertySymbols()")}}<br />{{jsxref("Object.keys()")}}<br />{{jsxref("Reflect.ownKeys()")}}
Expand Down Expand Up @@ -359,7 +359,7 @@ The following table summarizes the available traps available to `Proxy` objects.
</tr>
<tr>
<td>
{{jsxref("Global_Objects/Proxy/Proxy/apply", "handler.apply()")}}
{{jsxref("Proxy/Proxy/apply", "handler.apply()")}}
</td>
<td>
<code>proxy(..args)</code
Expand All @@ -373,7 +373,7 @@ The following table summarizes the available traps available to `Proxy` objects.
</tr>
<tr>
<td>
{{jsxref("Global_Objects/Proxy/Proxy/construct", "handler.construct()")}}
{{jsxref("Proxy/Proxy/construct", "handler.construct()")}}
</td>
<td>
<code>new proxy(...args)</code
Expand Down
16 changes: 8 additions & 8 deletions files/en-us/web/javascript/guide/numbers_and_dates/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ The following table summarizes the `Number` object's properties.
| {{jsxref("Number.MIN_SAFE_INTEGER")}} | Minimum safe integer in JavaScript (−2^53 + 1, or `−9007199254740991`) |
| {{jsxref("Number.MAX_SAFE_INTEGER")}} | Maximum safe integer in JavaScript (+2^53 − 1, or `+9007199254740991`) |

| Method | Description |
| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| {{jsxref("Number.parseFloat()")}} | Parses a string argument and returns a floating point number. Same as the global {{jsxref("parseFloat", "parseFloat()")}} function. |
| {{jsxref("Number.parseInt()")}} | Parses a string argument and returns an integer of the specified radix or base. Same as the global {{jsxref("parseInt", "parseInt()")}} function. |
| {{jsxref("Number.isFinite()")}} | Determines whether the passed value is a finite number. |
| {{jsxref("Number.isInteger()")}} | Determines whether the passed value is an integer. |
| {{jsxref("Number.isNaN()")}} | Determines whether the passed value is {{jsxref("Global_Objects/NaN", "NaN")}}. More robust version of the original global {{jsxref("Global_Objects/isNaN", "isNaN()")}}. |
| {{jsxref("Number.isSafeInteger()")}} | Determines whether the provided value is a number that is a _safe integer_. |
| Method | Description |
| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- |
| {{jsxref("Number.parseFloat()")}} | Parses a string argument and returns a floating point number. Same as the global {{jsxref("parseFloat()")}} function. |
| {{jsxref("Number.parseInt()")}} | Parses a string argument and returns an integer of the specified radix or base. Same as the global {{jsxref("parseInt()")}} function. |
| {{jsxref("Number.isFinite()")}} | Determines whether the passed value is a finite number. |
| {{jsxref("Number.isInteger()")}} | Determines whether the passed value is an integer. |
| {{jsxref("Number.isNaN()")}} | Determines whether the passed value is {{jsxref("NaN")}}. More robust version of the original global {{jsxref("isNaN()")}}. |
| {{jsxref("Number.isSafeInteger()")}} | Determines whether the provided value is a number that is a _safe integer_. |

The `Number` prototype provides methods for retrieving information from `Number` objects in various formats. The following table summarizes the methods of `Number.prototype`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ myCar.nonexistentProperty; // undefined
There are three native ways to list/traverse object properties:

- [`for...in`](/en-US/docs/Web/JavaScript/Reference/Statements/for...in) loops. This method traverses all of the enumerable string properties of an object as well as its prototype chain.
- {{jsxref("Object.keys", "Object.keys(myObj)")}}. This method returns an array with only the enumerable own string property names ("keys") in the object `myObj`, but not those in the prototype chain.
- {{jsxref("Object.getOwnPropertyNames", "Object.getOwnPropertyNames(myObj)")}}. This method returns an array containing all the own string property names in the object `myObj`, regardless of if they are enumerable or not.
- {{jsxref("Object.keys()")}}. This method returns an array with only the enumerable own string property names ("keys") in the object `myObj`, but not those in the prototype chain.
- {{jsxref("Object.getOwnPropertyNames()")}}. This method returns an array containing all the own string property names in the object `myObj`, regardless of if they are enumerable or not.

You can use the bracket notation with [`for...in`](/en-US/docs/Web/JavaScript/Reference/Statements/for...in) to iterate over all the enumerable properties of an object. To illustrate how this works, the following function displays the properties of the object when you pass the object and the object's name as arguments to the function:

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 @@ -63,7 +63,7 @@ Head over to our [Learning Area JavaScript topic](/en-US/docs/Learn/JavaScript)
- [JavaScript data structures](/en-US/docs/Web/JavaScript/Data_structures)
- : Overview of available data structures in JavaScript.
- [Equality comparisons and sameness](/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness)
- : JavaScript provides three different value comparison operations: strict equality using `===`, loose equality using `==`, and the {{jsxref("Global_Objects/Object/is", "Object.is()")}} method.
- : JavaScript provides three different value comparison operations: strict equality using `===`, loose equality using `==`, and the {{jsxref("Object.is()")}} method.
- [Enumerability and ownership of properties](/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties)
- : How different methods that visit a group of object properties one-by-one handle the enumerability and ownership of properties.
- [Closures](/en-US/docs/Web/JavaScript/Closures)
Expand Down
4 changes: 2 additions & 2 deletions files/en-us/web/javascript/language_overview/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ const circumference = 2 * Math.PI * r;

There are three ways to convert a string to a number:

- {{jsxref("Global_Objects/parseInt", "parseInt()")}}, which parses the string for an integer.
- {{jsxref("Global_Objects/parseFloat", "parseFloat()")}}, which parses the string for a floating-point number.
- {{jsxref("parseInt()")}}, which parses the string for an integer.
- {{jsxref("parseFloat()")}}, which parses the string for a floating-point number.
- The [`Number()`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/Number) function, which parses a string as if it's a number literal and supports many different number representations.

You can also use the [unary plus `+`](/en-US/docs/Web/JavaScript/Reference/Operators/Unary_plus) as a shorthand for `Number()`.
Expand Down
Loading

0 comments on commit fb85334

Please sign in to comment.