Skip to content

Commit

Permalink
Improve jsxref macro typesetting (mdn#20298)
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena authored Sep 5, 2022
1 parent 12c70e5 commit 8d76e99
Show file tree
Hide file tree
Showing 28 changed files with 134 additions and 161 deletions.
2 changes: 1 addition & 1 deletion files/en-us/web/javascript/data_structures/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ console.log(42 / +0); // Infinity
console.log(42 / -0); // -Infinity
```

Although a number often represents only its value, JavaScript provides {{jsxref("Operators", "binary (bitwise) operators")}}.
Although a number often represents only its value, JavaScript provides [bitwise operators](/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#bitwise_operators).

> **Note:** Although bitwise operators _can_ be used to represent several Boolean values within a single number using [bit masking](https://en.wikipedia.org/wiki/Mask_%28computing%29), this is usually considered a bad practice. JavaScript offers other means to represent a set of Booleans (like an array of Booleans, or an object with Boolean values assigned to named properties). Bit masking also tends to make the code more difficult to read, understand, and maintain.
Expand Down
22 changes: 11 additions & 11 deletions files/en-us/web/javascript/reference/functions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -644,16 +644,16 @@ are no brackets "()" after the function name so the actual function is not calle

## See also

- {{jsxref("Statements/function", "function statement")}}
- {{jsxref("Operators/function", "function expression")}}
- {{jsxref("Statements/function*", "function* statement")}}
- {{jsxref("Operators/function*", "function* expression")}}
- [`function` declaration](/en-US/docs/Web/JavaScript/Reference/Statements/function)
- [`function` declaration](/en-US/docs/Web/JavaScript/Reference/Operators/function)
- [`function*` declaration](/en-US/docs/Web/JavaScript/Reference/Statements/function*)
- [`function*` expressions](/en-US/docs/Web/JavaScript/Reference/Operators/function*)
- {{jsxref("Function")}}
- {{jsxref("GeneratorFunction")}}
- {{jsxref("Functions/Arrow_functions", "Arrow functions")}}
- {{jsxref("Functions/Default_parameters", "Default parameters")}}
- {{jsxref("Functions/rest_parameters", "Rest parameters")}}
- {{jsxref("Functions/arguments", "Arguments object")}}
- {{jsxref("Functions/get", "getter")}}
- {{jsxref("Functions/set", "setter")}}
- {{jsxref("Functions/Method_definitions", "Method definitions")}}
- [Arrow functions](/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions)
- [Rest parameters](/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters)
- [Default parameters](/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters)
- [Method definitions](/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions)
- [getter](/en-US/docs/Web/JavaScript/Reference/Functions/get)
- [setter](/en-US/docs/Web/JavaScript/Reference/Functions/set)
- [The `arguments` object](/en-US/docs/Web/JavaScript/Reference/Functions/arguments)
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ If no elements satisfy the testing function, -1 is returned.

{{EmbedInteractiveExample("pages/js/array-findlastindex.html","shorter")}}

See also the {{jsxref("Array/findLast()", "findLast()")}} method, which returns the value of last element that satisfies the testing function (rather than its index).
See also the {{jsxref("Array/findLast", "findLast()")}} method, which returns the value of last element that satisfies the testing function (rather than its index).

## Syntax

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The [`ArrayBuffer()`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayB

## Static methods

- {{jsxref("ArrayBuffer.isView", "ArrayBuffer.isView(<var>arg</var>)")}}
- {{jsxref("ArrayBuffer.isView()")}}
- : Returns `true` if `arg` is one of the ArrayBuffer views, such as [typed array objects](/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) or a {{jsxref("DataView")}}. Returns `false` otherwise.

## Instance properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ AsyncFunction(arg0, arg1, /* … ,*/ argN, functionBody)

## Description

{{jsxref("Statements/async_function", "async function")}} objects created with the
[Async function](/en-US/docs/Web/JavaScript/Reference/Statements/async_function) objects created with the
`AsyncFunction` constructor are parsed when the function is created. This is
less efficient than declaring an async function with an
{{jsxref("Statements/async_function", "async function expression")}} and calling it
[`async function` expression](/en-US/docs/Web/JavaScript/Reference/Operators/async_function) and calling it
within your code, because such functions are parsed with the rest of the code.

All arguments passed to the function, except the last, are treated as the names of the identifiers of the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ main()

- {{jsxref("Statements/function*", "function*", "", 1)}}
- {{jsxref("Statements/async_function*", "async function*", "", 1)}}
- {{jsxref("Operators/function*", '<code>function*</code> expression', "", 1)}}
- [`function*` expression](/en-US/docs/Web/JavaScript/Reference/Operators/function*)
- {{jsxref("GeneratorFunction", "Generator Function", "", 1)}}
- {{jsxref("AsyncGeneratorFunction", "Async Generator Function", "", 1)}}
- [Iterators and generators](/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators)
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ AsyncGeneratorFunction(arg0, arg1, /* … ,*/ argN, functionBody)

## Description

Async generator function objects created with the `AsyncGeneratorFunction` constructor are parsed when the function is created. This is less efficient than declaring a generator function with an {{jsxref("Operators/async_function*", "async function* expression")}} and calling it within your code, because such functions are parsed with the rest of the code.
Async generator function objects created with the `AsyncGeneratorFunction` constructor are parsed when the function is created. This is less efficient than declaring a generator function with an [`async function*` expression](/en-US/docs/Web/JavaScript/Reference/Statements/async_function*) and calling it within your code, because such functions are parsed with the rest of the code.

All arguments passed to the function, except the last, are treated as the names of the identifiers of the parameters in the function to be created, in the order in which they are passed.

Expand Down Expand Up @@ -85,7 +85,7 @@ asyncGen.next().then((res) => console.log(res.value)); // 20

- {{jsxref("Statements/function*", "function*")}}
- {{jsxref("Statements/async_function*", "async function*")}}
- {{jsxref("Operators/function*", '<code>function*</code> expression', "", 1)}}
- [`function*` expression](/en-US/docs/Web/JavaScript/Reference/Operators/function*)
- {{jsxref("Global_Objects/AsyncGenerator", "AsyncGenerator")}}
- {{jsxref("Global_Objects/Generator", "Generator")}}
- {{jsxref("Global_Objects/GeneratorFunction", "GeneratorFunction")}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ console.log(generator.next().value); // 2
## See also

- {{JSxRef("Statements/function*", "function*")}}
- {{JSxRef("Operators/function*", '<code>function*</code> expression', "", 1)}}
- [`function*` expression](/en-US/docs/Web/JavaScript/Reference/Operators/function*)
- {{JSxRef("GeneratorFunction")}}
- [The Iterator protocol](/en-US/docs/Web/JavaScript/Reference/Iteration_protocols)
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ GeneratorFunction(arg0, arg1, /* … ,*/ argN, functionBody)
{{jsxref("Statements/function*", "Generator function", "", "1")}} objects created with a
constructor are parsed when the function is created. That
is less efficient than declaring a generator function with a
{{jsxref("Statements/function*", "function* expression")}} and calling it within your
[`function*` expression](/en-US/docs/Web/JavaScript/Reference/Statements/function*) and calling it within your
code, because such functions are parsed with the rest of the code.

All arguments passed to the function, except the last, are treated as the names of the identifiers of the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,14 @@ whitespace characters.

## Static methods

- {{jsxref("JSON.parse()", "JSON.parse(<var>text</var>[, <var>reviver</var>])")}}
- {{jsxref("JSON.parse()")}}
- : Parse the string `text` as JSON, optionally transform the
produced value and its properties, and return the value. Any violations of the JSON
syntax, including those pertaining to the differences between JavaScript and JSON,
cause a {{jsxref("SyntaxError")}} to be thrown. The `reviver`
option allows for interpreting what the `replacer` has used to
stand in for other datatypes.
- {{jsxref("JSON.stringify()", "JSON.stringify(<var>value</var>[,
<var>replacer</var>[, <var>space</var>]])")}}
- {{jsxref("JSON.stringify()")}}
- : Return a JSON string corresponding to the specified value, optionally including only
certain properties or replacing property values in a user-defined manner. By default,
all instances of {{jsxref("undefined")}} are replaced with [`null`](/en-US/docs/Web/JavaScript/Reference/Operators/null), and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ browser-compat: javascript.builtins.Map.@@iterator
---
{{JSRef}}

<p class="seoSummary">The initial value of the <strong><code>@@iterator</code></strong>
property is the same function object as the initial value of the
{{jsxref("Map.prototype.entries()", "entries")}} method.</p>
The initial value of the **`@@iterator`** property is the same function object as the initial value of the {{jsxref("Map.prototype.entries()")}} method.

{{EmbedInteractiveExample("pages/js/map-prototype-@@iterator.html")}}

Expand Down
70 changes: 35 additions & 35 deletions files/en-us/web/javascript/reference/global_objects/math/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,75 +43,75 @@ Unlike many other global objects, `Math` is not a constructor. All properties an

## Static methods

- {{jsxref("Global_Objects/Math/abs", "Math.abs(<var>x</var>)")}}
- {{jsxref("Math.abs()")}}
- : Returns the absolute value of `x`.
- {{jsxref("Global_Objects/Math/acos", "Math.acos(<var>x</var>)")}}
- {{jsxref("Math.acos()")}}
- : Returns the arccosine of `x`.
- {{jsxref("Global_Objects/Math/acosh", "Math.acosh(<var>x</var>)")}}
- {{jsxref("Math.acosh()")}}
- : Returns the hyperbolic arccosine of `x`.
- {{jsxref("Global_Objects/Math/asin", "Math.asin(<var>x</var>)")}}
- {{jsxref("Math.asin()")}}
- : Returns the arcsine of `x`.
- {{jsxref("Global_Objects/Math/asinh", "Math.asinh(<var>x</var>)")}}
- {{jsxref("Math.asinh()")}}
- : Returns the hyperbolic arcsine of a number.
- {{jsxref("Global_Objects/Math/atan", "Math.atan(<var>x</var>)")}}
- {{jsxref("Math.atan()")}}
- : Returns the arctangent of `x`.
- {{jsxref("Global_Objects/Math/atanh", "Math.atanh(<var>x</var>)")}}
- {{jsxref("Math.atanh()")}}
- : Returns the hyperbolic arctangent of `x`.
- {{jsxref("Global_Objects/Math/atan2", "Math.atan2(<var>y</var>, <var>x</var>)")}}
- {{jsxref("Math.atan2()")}}
- : Returns the arctangent of the quotient of its arguments.
- {{jsxref("Global_Objects/Math/cbrt", "Math.cbrt(<var>x</var>)")}}
- {{jsxref("Math.cbrt()")}}
- : Returns the cube root of `x`.
- {{jsxref("Global_Objects/Math/ceil", "Math.ceil(<var>x</var>)")}}
- {{jsxref("Math.ceil()")}}
- : Returns the smallest integer greater than or equal to `x`.
- {{jsxref("Global_Objects/Math/clz32", "Math.clz32(<var>x</var>)")}}
- {{jsxref("Math.clz32()")}}
- : Returns the number of leading zero bits of the 32-bit integer `x`.
- {{jsxref("Global_Objects/Math/cos", "Math.cos(<var>x</var>)")}}
- {{jsxref("Math.cos()")}}
- : Returns the cosine of `x`.
- {{jsxref("Global_Objects/Math/cosh", "Math.cosh(<var>x</var>)")}}
- {{jsxref("Math.cosh()")}}
- : Returns the hyperbolic cosine of `x`.
- {{jsxref("Global_Objects/Math/exp", "Math.exp(<var>x</var>)")}}
- {{jsxref("Math.exp()")}}
- : Returns e<sup>x</sup>, where x is the argument, and e is Euler's constant (`2.718`…, the base of the natural logarithm).
- {{jsxref("Global_Objects/Math/expm1", "Math.expm1(<var>x</var>)")}}
- {{jsxref("Math.expm1()")}}
- : Returns subtracting `1` from `exp(x)`.
- {{jsxref("Global_Objects/Math/floor", "Math.floor(<var>x</var>)")}}
- {{jsxref("Math.floor()")}}
- : Returns the largest integer less than or equal to `x`.
- {{jsxref("Global_Objects/Math/fround", "Math.fround(<var>x</var>)")}}
- {{jsxref("Math.fround()")}}
- : Returns the nearest [single precision](https://en.wikipedia.org/wiki/Single-precision_floating-point_format) float representation of `x`.
- {{jsxref("Global_Objects/Math/hypot", "Math.hypot([<var>x</var>[, <var>y</var>[, …]]])")}}
- {{jsxref("Math.hypot()")}}
- : Returns the square root of the sum of squares of its arguments.
- {{jsxref("Global_Objects/Math/imul", "Math.imul(<var>x</var>, <var>y</var>)")}}
- {{jsxref("Math.imul()")}}
- : Returns the result of the 32-bit integer multiplication of `x` and `y`.
- {{jsxref("Global_Objects/Math/log", "Math.log(<var>x</var>)")}}
- {{jsxref("Math.log()")}}
- : Returns the natural logarithm (㏒<sub>e</sub>; also, ㏑) of `x`.
- {{jsxref("Global_Objects/Math/log1p", "Math.log1p(<var>x</var>)")}}
- {{jsxref("Math.log1p()")}}
- : Returns the natural logarithm (㏒<sub>e</sub>; also ㏑) of `1 + x` for the number `x`.
- {{jsxref("Global_Objects/Math/log10", "Math.log10(<var>x</var>)")}}
- {{jsxref("Math.log10()")}}
- : Returns the base-10 logarithm of `x`.
- {{jsxref("Global_Objects/Math/log2", "Math.log2(<var>x</var>)")}}
- {{jsxref("Math.log2()")}}
- : Returns the base-2 logarithm of `x`.
- {{jsxref("Global_Objects/Math/max", "Math.max([<var>x</var>[, <var>y</var>[, …]]])")}}
- {{jsxref("Math.max()")}}
- : Returns the largest of zero or more numbers.
- {{jsxref("Global_Objects/Math/min", "Math.min([<var>x</var>[, <var>y</var>[, …]]])")}}
- {{jsxref("Math.min()")}}
- : Returns the smallest of zero or more numbers.
- {{jsxref("Global_Objects/Math/pow", "Math.pow(<var>x</var>, <var>y</var>)")}}
- {{jsxref("Math.pow()")}}
- : Returns base `x` to the exponent power `y` (that is, `x`<sup><code>y</code></sup>).
- {{jsxref("Global_Objects/Math/random", "Math.random()")}}
- {{jsxref("Math.random()")}}
- : Returns a pseudo-random number between `0` and `1`.
- {{jsxref("Global_Objects/Math/round", "Math.round(<var>x</var>)")}}
- {{jsxref("Math.round()")}}
- : Returns the value of the number `x` rounded to the nearest integer.
- {{jsxref("Global_Objects/Math/sign", "Math.sign(<var>x</var>)")}}
- {{jsxref("Math.sign()")}}
- : Returns the sign of the `x`, indicating whether `x` is positive, negative, or zero.
- {{jsxref("Global_Objects/Math/sin", "Math.sin(<var>x</var>)")}}
- {{jsxref("Math.sin()")}}
- : Returns the sine of `x`.
- {{jsxref("Global_Objects/Math/sinh", "Math.sinh(<var>x</var>)")}}
- {{jsxref("Math.sinh()")}}
- : Returns the hyperbolic sine of `x`.
- {{jsxref("Global_Objects/Math/sqrt", "Math.sqrt(<var>x</var>)")}}
- {{jsxref("Math.sqrt()")}}
- : Returns the positive square root of `x`.
- {{jsxref("Global_Objects/Math/tan", "Math.tan(<var>x</var>)")}}
- {{jsxref("Math.tan()")}}
- : Returns the tangent of `x`.
- {{jsxref("Global_Objects/Math/tanh", "Math.tanh(<var>x</var>)")}}
- {{jsxref("Math.tanh()")}}
- : Returns the hyperbolic tangent of `x`.
- {{jsxref("Global_Objects/Math/trunc", "Math.trunc(<var>x</var>)")}}
- {{jsxref("Math.trunc()")}}
- : Returns the integer portion of `x`, removing any fractional digits.

## Examples
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,22 @@ When `Number` is called as a constructor (with `new`), it creates a {{jsxref("Nu
- : Determine whether the passed value is an integer.
- {{jsxref("Number.isSafeInteger()")}}
- : Determine whether the passed value is a safe integer (number between -(2<sup>53</sup> - 1) and 2<sup>53</sup> - 1).
- {{jsxref("Number.parseFloat()", "Number.parseFloat(<var>string</var>)")}}
- {{jsxref("Number.parseFloat()")}}
- : This is the same as the global {{jsxref("parseFloat", "parseFloat()")}} function.
- {{jsxref("Number.parseInt()", "Number.parseInt(<var>string</var>, [<var>radix</var>])")}}
- {{jsxref("Number.parseInt()")}}
- : This is the same as the global {{jsxref("parseInt", "parseInt()")}} function.

## Instance methods

- {{jsxref("Number.prototype.toExponential()" ,"Number.prototype.toExponential(<var>fractionDigits</var>)")}}
- {{jsxref("Number.prototype.toExponential()")}}
- : Returns a string representing the number in exponential notation.
- {{jsxref("Number.prototype.toFixed()", "Number.prototype.toFixed(<var>digits</var>)")}}
- {{jsxref("Number.prototype.toFixed()")}}
- : Returns a string representing the number in fixed-point notation.
- {{jsxref("Number.prototype.toLocaleString()", "Number.prototype.toLocaleString([<var>locales</var> [, <var>options</var>]])")}}
- {{jsxref("Number.prototype.toLocaleString()")}}
- : Returns a string with a language sensitive representation of this number. Overrides the {{jsxref("Object.prototype.toLocaleString()")}} method.
- {{jsxref("Number.prototype.toPrecision()", "Number.prototype.toPrecision(<var>precision</var>)")}}
- {{jsxref("Number.prototype.toPrecision()")}}
- : Returns a string representing the number to a specified precision in fixed-point or exponential notation.
- {{jsxref("Number.prototype.toString()", "Number.prototype.toString([<var>radix</var>])")}}
- {{jsxref("Number.prototype.toString()")}}
- : Returns a string representing the specified object in the specified _radix_ ("base"). Overrides the {{jsxref("Object.prototype.toString()")}} method.
- {{jsxref("Number.prototype.valueOf()")}}
- : Returns the primitive value of the specified object. Overrides the {{jsxref("Object.prototype.valueOf()")}} method.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ Object.entries(obj).forEach(([key, value]) => {
});
```

### Converting an `Object` to a `Map`
### Converting an Object to a Map

The {{jsxref("Map", "new Map()")}} constructor accepts an iterable of
The {{jsxref("Map/Map", "Map()")}} constructor accepts an iterable of
`entries`. With `Object.entries`, you can easily convert from
{{jsxref("Object")}} to {{jsxref("Map")}}:

Expand All @@ -99,7 +99,7 @@ const map = new Map(Object.entries(obj));
console.log(map); // Map(2) {"foo" => "bar", "baz" => 42}
```

### Iterating through an `Object`
### Iterating through an Object

Using [Array Destructuring](/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#array_destructuring), you can iterate through objects easily.

Expand Down
Loading

0 comments on commit 8d76e99

Please sign in to comment.