Skip to content

Commit 5bdcf72

Browse files
estelleJosh-Cena
andauthored
Remove "simple" part 6: javascript (#36777)
* Remove simple part6: javascript part1 * forgot to save * there were only 5 more examples * Apply suggestions from code review Co-authored-by: Joshua Chen <[email protected]> * Update files/en-us/web/javascript/reference/functions/arrow_functions/index.md * Update files/en-us/web/javascript/reference/global_objects/string/matchall/index.md --------- Co-authored-by: Joshua Chen <[email protected]>
1 parent b7bf812 commit 5bdcf72

File tree

42 files changed

+51
-51
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+51
-51
lines changed

files/en-us/web/javascript/guide/functions/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ A **function definition** (also called a **function declaration**, or **function
2020
- A list of parameters to the function, enclosed in parentheses and separated by commas.
2121
- The JavaScript statements that define the function, enclosed in curly braces, `{ /* … */ }`.
2222

23-
For example, the following code defines a simple function named `square`:
23+
For example, the following code defines a function named `square`:
2424

2525
```js
2626
function square(number) {

files/en-us/web/javascript/guide/grammar_and_types/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ The following table lists the special characters that you can use in JavaScript
666666
| `\XXX` | The character with the Latin-1 encoding specified by up to three octal digits `XXX` between `0` and `377`. For example, `\251` is the octal sequence for the copyright symbol. |
667667
| `\xXX` | The character with the Latin-1 encoding specified by the two hexadecimal digits `XX` between `00` and `FF`. For example, `\xA9` is the hexadecimal sequence for the copyright symbol. |
668668
| `\uXXXX` | The Unicode character specified by the four hexadecimal digits `XXXX`. For example, `\u00A9` is the Unicode sequence for the copyright symbol. See [Unicode escape sequences](/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#string_literals). |
669-
| `\u{XXXXX}` | Unicode code point escapes. For example, `\u{2F804}` is the same as the simple Unicode escapes `\uD87E\uDC04`. |
669+
| `\u{XXXXX}` | Unicode code point escapes. For example, `\u{2F804}` is the same as the Unicode escapes `\uD87E\uDC04`. |
670670

671671
#### Escaping characters
672672

files/en-us/web/javascript/guide/indexed_collections/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ console.log(cats); // [ <3 empty items> ]
175175

176176
### Iterating over arrays
177177

178-
A common operation is to iterate over the values of an array, processing each one in some way. The simplest way to do this is as follows:
178+
A common operation is to iterate over the values of an array, processing each one in some way, as follows:
179179

180180
```js
181181
const colors = ["red", "green", "blue"];
@@ -509,7 +509,7 @@ You can transform back and forth between arrays and other data structures.
509509

510510
The {{jsxref("Object.groupBy()")}} method can be used to group the elements of an array, using a test function that returns a string indicating the group of the current element.
511511

512-
Here we have a simple inventory array that contains "food" objects that have a `name` and a `type`.
512+
Here we have an inventory array that contains "food" objects that have a `name` and a `type`.
513513

514514
```js
515515
const inventory = [

files/en-us/web/javascript/guide/iterators_and_generators/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The most common iterator in JavaScript is the Array iterator, which returns each
3232

3333
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")}}.
3434

35-
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`.
35+
Here is an example which can do just that. It allows creation of a 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`.
3636

3737
```js
3838
function makeRangeIterator(start = 0, end = Infinity, step = 1) {

files/en-us/web/javascript/guide/keyed_collections/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This chapter introduces collections of data which are indexed by a key; `Map` an
1212

1313
### Map object
1414

15-
A {{jsxref("Map")}} object is a simple key/value map and can iterate its elements in insertion order.
15+
A {{jsxref("Map")}} object is a key/value map that can iterate its elements in insertion order.
1616

1717
The following code shows some basic operations with a `Map`. See also the {{jsxref("Map")}} reference page for more examples and the complete API. You can use a {{jsxref("Statements/for...of", "for...of")}} loop to return an array of `[key, value]` for each iteration.
1818

files/en-us/web/javascript/guide/modules/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ All modern browsers support module features natively without needing transpilati
1818

1919
## Introducing an example
2020

21-
To demonstrate usage of modules, we've created a [simple set of examples](https://github.com/mdn/js-examples/tree/main/module-examples) that you can find on GitHub. These examples demonstrate a simple set of modules that create a [`<canvas>`](/en-US/docs/Web/HTML/Element/canvas) element on a webpage, and then draw (and report information about) different shapes on the canvas.
21+
To demonstrate usage of modules, we've created a [set of examples](https://github.com/mdn/js-examples/tree/main/module-examples) that you can find on GitHub. These examples demonstrate a set of modules that create a [`<canvas>`](/en-US/docs/Web/HTML/Element/canvas) element on a webpage, and then draw (and report information about) different shapes on the canvas.
2222

2323
These are fairly trivial, but have been kept deliberately simple to demonstrate modules clearly.
2424

files/en-us/web/javascript/guide/text_formatting/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ JavaScript's [String](/en-US/docs/Glossary/String) type is used to represent tex
1414

1515
### String literals
1616

17-
You can create simple strings using either single or double quotes:
17+
You can declare strings in source code using either single or double quotes:
1818

1919
```js-nolint
2020
'foo'
@@ -41,7 +41,7 @@ The Unicode escape sequences require at least four hexadecimal digits following
4141

4242
#### Unicode code point escapes
4343

44-
With Unicode code point escapes, any character can be escaped using hexadecimal numbers so that it is possible to use Unicode code points up to `0x10FFFF`. With simple Unicode escapes it is often necessary to write the surrogate halves separately to achieve the same result.
44+
With Unicode code point escapes, any character can be escaped using hexadecimal numbers so that it is possible to use Unicode code points up to `0x10FFFF`. With the four-digit Unicode escapes it is often necessary to write the surrogate halves separately to achieve the same result.
4545

4646
See also {{jsxref("String.fromCodePoint()")}} or {{jsxref("String.prototype.codePointAt()")}}.
4747

files/en-us/web/javascript/guide/working_with_objects/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ page-type: guide
66

77
{{jsSidebar("JavaScript Guide")}} {{PreviousNext("Web/JavaScript/Guide/Keyed_collections", "Web/JavaScript/Guide/Using_classes")}}
88

9-
JavaScript is designed on a simple object-based paradigm. An object is a collection of [properties](/en-US/docs/Glossary/Property/JavaScript), and a property is an association between a name (or _key_) and a value. A property's value can be a function, in which case the property is known as a [method](/en-US/docs/Glossary/Method).
9+
JavaScript is designed on an object-based paradigm. An object is a collection of [properties](/en-US/docs/Glossary/Property/JavaScript), and a property is an association between a name (or _key_) and a value. A property's value can be a function, in which case the property is known as a [method](/en-US/docs/Glossary/Method).
1010

1111
Objects in JavaScript, just as in many other programming languages, can be compared to objects in real life. In JavaScript, an object is a standalone entity, with properties and type. Compare it with a cup, for example. A cup is an object, with properties. A cup has a color, a design, weight, a material it is made of, etc. The same way, JavaScript objects can have properties, which define their characteristics.
1212

files/en-us/web/javascript/reference/functions/arrow_functions/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ const obj = {
395395
// Setting "num" on globalThis to show how it is NOT used.
396396
globalThis.num = 42;
397397

398-
// A simple traditional function to operate on "this"
398+
// A traditional function to operate on "this"
399399
const add = function (a, b, c) {
400400
return this.num + a + b + c;
401401
};

files/en-us/web/javascript/reference/global_objects/array/reduce/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ The `reduce()` method is an [iterative method](/en-US/docs/Web/JavaScript/Refere
5454

5555
Unlike other [iterative methods](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#iterative_methods), `reduce()` does not accept a `thisArg` argument. `callbackFn` is always called with `undefined` as `this`, which gets substituted with `globalThis` if `callbackFn` is non-strict.
5656

57-
`reduce()` is a central concept in [functional programming](https://en.wikipedia.org/wiki/Functional_programming), where it's not possible to mutate any value, so in order to accumulate all values in an array, one must return a new accumulator value on every iteration. This convention propagates to JavaScript's `reduce()`: you should use [spreading](/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax) or other copying methods where possible to create new arrays and objects as the accumulator, rather than mutating the existing one. If you decided to mutate the accumulator instead of copying it, remember to still return the modified object in the callback, or the next iteration will receive undefined. However, note that copying the accumulator may in turn lead to increased memory usage and degraded performance — see [When to not use reduce()](#when_to_not_use_reduce) for more details. In such cases, to avoid bad performance and unreadable code, it's better to use a simple `for` loop instead.
57+
`reduce()` is a central concept in [functional programming](https://en.wikipedia.org/wiki/Functional_programming), where it's not possible to mutate any value, so in order to accumulate all values in an array, one must return a new accumulator value on every iteration. This convention propagates to JavaScript's `reduce()`: you should use [spreading](/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax) or other copying methods where possible to create new arrays and objects as the accumulator, rather than mutating the existing one. If you decided to mutate the accumulator instead of copying it, remember to still return the modified object in the callback, or the next iteration will receive undefined. However, note that copying the accumulator may in turn lead to increased memory usage and degraded performance — see [When to not use reduce()](#when_to_not_use_reduce) for more details. In such cases, to avoid bad performance and unreadable code, it's better to use a `for` loop instead.
5858

5959
The `reduce()` method is [generic](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#generic_array_methods). It only expects the `this` value to have a `length` property and integer-keyed properties.
6060

@@ -268,7 +268,7 @@ const countedNames = names.reduce((allNames, name) => {
268268

269269
This code is ill-performing, because each iteration has to copy the entire `allNames` object, which could be big, depending how many unique names there are. This code has worst-case `O(N^2)` performance, where `N` is the length of `names`.
270270

271-
A better alternative is to _mutate_ the `allNames` object on each iteration. However, if `allNames` gets mutated anyway, you may want to convert the `reduce()` to a simple `for` loop instead, which is much clearer:
271+
A better alternative is to _mutate_ the `allNames` object on each iteration. However, if `allNames` gets mutated anyway, you may want to convert the `reduce()` to a `for` loop instead, which is much clearer:
272272

273273
```js example-bad
274274
const names = ["Alice", "Bob", "Tiff", "Bruce", "Alice"];

files/en-us/web/javascript/reference/global_objects/asyncgenerator/next/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ A {{jsxref("Promise")}} which when resolved returns an {{jsxref("Object")}} with
3636

3737
### Using next()
3838

39-
The following example shows a simple generator and the object that the `next` method returns:
39+
The following example shows a generator and the object that the `next` method returns:
4040

4141
```js
4242
// An async task. Pretend it's doing something more useful

files/en-us/web/javascript/reference/global_objects/asyncgenerator/return/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The `return()` method, when called, can be seen as if a `return value;` statemen
4040

4141
### Using return()
4242

43-
The following example shows a simple async generator and the `return` method.
43+
The following example shows an async generator and the `return` method.
4444

4545
```js
4646
// An async task. Pretend it's doing something more useful

files/en-us/web/javascript/reference/global_objects/asyncgenerator/throw/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ If the exception is caught by a [`try...catch`](/en-US/docs/Web/JavaScript/Refer
3737

3838
### Using throw()
3939

40-
The following example shows a simple generator and an error that is thrown using the `throw` method. An error can be caught by a {{jsxref("Statements/try...catch", "try...catch")}} block as usual.
40+
The following example shows a generator and an error that is thrown using the `throw` method. An error can be caught by a {{jsxref("Statements/try...catch", "try...catch")}} block as usual.
4141

4242
```js
4343
// An async task. Pretend it's doing something more useful

files/en-us/web/javascript/reference/global_objects/function/apply/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ let max = Math.max.apply(null, numbers);
9898

9999
let min = Math.min.apply(null, numbers);
100100

101-
// vs. simple loop based algorithm
101+
// vs. loop based algorithm
102102
max = -Infinity;
103103
min = +Infinity;
104104

files/en-us/web/javascript/reference/global_objects/function/bind/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ The bound function also inherits the [prototype chain](/en-US/docs/Web/JavaScrip
9191

9292
### Creating a bound function
9393

94-
The simplest use of `bind()` is to make a function that, no matter how it is called, is called with a particular `this` value.
94+
The most common use of `bind()` is to make a function that, no matter how it is called, is called with a particular `this` value.
9595

9696
A common mistake for new JavaScript programmers is to extract a method from an object, then to later call that function and expect it to use the original object as its `this` (e.g., by using the method in callback-based code).
9797

@@ -130,7 +130,7 @@ In fact, some built-in "methods" are also getters that return bound functions
130130

131131
### Partially applied functions
132132

133-
The next simplest use of `bind()` is to make a function with pre-specified initial arguments.
133+
Another use of `bind()` is to make a function with pre-specified initial arguments.
134134

135135
These arguments (if any) follow the provided `this` value and are then inserted at the start of the arguments passed to the target function, followed by whatever arguments are passed to the bound function at the time it is called.
136136

files/en-us/web/javascript/reference/global_objects/generator/next/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ An {{jsxref("Object")}} with two properties:
4545

4646
### Using next()
4747

48-
The following example shows a simple generator and the object that the
48+
The following example shows a generator and the object that the
4949
`next` method returns:
5050

5151
```js

files/en-us/web/javascript/reference/global_objects/generator/return/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ The `return()` method, when called, can be seen as if a `return value;` statemen
4242

4343
### Using return()
4444

45-
The following example shows a simple generator and the `return` method.
45+
The following example shows a generator and the `return` method.
4646

4747
```js
4848
function* gen() {

files/en-us/web/javascript/reference/global_objects/generator/throw/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ The `throw()` method, when called, can be seen as if a `throw exception;` statem
4545

4646
### Using throw()
4747

48-
The following example shows a simple generator and an error that is thrown using the `throw` method. An error can be caught by a {{jsxref("Statements/try...catch", "try...catch")}} block as usual.
48+
The following example shows a generator and an error that is thrown using the `throw` method. An error can be caught by a {{jsxref("Statements/try...catch", "try...catch")}} block as usual.
4949

5050
```js
5151
function* gen() {

files/en-us/web/javascript/reference/global_objects/iterator/iterator/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ You can also use {{jsxref("Iterator.from()")}} to create an `Iterator` instance
4040

4141
### Subclassing Iterator
4242

43-
The following example defines a custom data structure, `Range`, which allows iteration. The simplest way to make an object iterable is to provide an [`[Symbol.iterator]()`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator) method in the form of a generator function:
43+
The following example defines a custom data structure, `Range`, which allows iteration. To make an object iterable, we can provide an [`[Symbol.iterator]()`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator) method in the form of a generator function:
4444

4545
```js
4646
class Range {

files/en-us/web/javascript/reference/global_objects/map/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ cases:
9292
<th scope="row">Key Order</th>
9393
<td>
9494
<p>
95-
The keys in <code>Map</code> are ordered in a simple, straightforward
95+
The keys in <code>Map</code> are ordered in a straightforward
9696
way: A <code>Map</code> object iterates entries, keys, and values in
9797
the order of entry insertion.
9898
</p>

files/en-us/web/javascript/reference/global_objects/math/atan2/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The angle in radians (between -π and π, inclusive) between the positive x-axis
3232

3333
The `Math.atan2()` method measures the counterclockwise angle θ, in radians, between the positive x-axis and the point `(x, y)`. Note that the arguments to this function pass the y-coordinate first and the x-coordinate second.
3434

35-
![A simple diagram showing the angle returned by atan2(y, x)](atan2.png)
35+
![A diagram showing the angle returned by atan2(y, x)](atan2.png)
3636

3737
`Math.atan2()` is passed separate `x` and `y` arguments, while [`Math.atan()`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan) is passed the ratio of those two arguments. `Math.atan2(y, x)` differs from `Math.atan(y / x)` in the following cases:
3838

files/en-us/web/javascript/reference/global_objects/math/pow/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Because `pow()` is a static method of `Math`, use it as `Math.pow()`, rather tha
5252
### Using Math.pow()
5353

5454
```js
55-
// Simple cases
55+
// Basic cases
5656
Math.pow(7, 2); // 49
5757
Math.pow(7, 3); // 343
5858
Math.pow(2, 10); // 1024

files/en-us/web/javascript/reference/global_objects/math/trunc/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The integer part of `x`.
2828

2929
## Description
3030

31-
Unlike the other three `Math` methods: {{jsxref("Math.floor()")}}, {{jsxref("Math.ceil()")}} and {{jsxref("Math.round()")}}, the way `Math.trunc()` works is very simple. It _truncates_ (cuts off) the dot and the digits to the right of it, no matter whether the argument is a positive or negative number.
31+
The way `Math.trunc()` works is more straightforward than the other three `Math` methods: {{jsxref("Math.floor()")}}, {{jsxref("Math.ceil()")}} and {{jsxref("Math.round()")}}; it _truncates_ (cuts off) the dot and the digits to the right of it, no matter whether the argument is a positive or negative number.
3232

3333
Because `trunc()` is a static method of `Math`, you always use it as `Math.trunc()`, rather than as a method of a `Math` object you created (`Math` is not a constructor).
3434

files/en-us/web/javascript/reference/global_objects/object/keys/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ If you need the property values, use {{jsxref("Object.values()")}} instead. If y
3737
### Using Object.keys()
3838

3939
```js
40-
// Simple array
40+
// Basic array
4141
const arr = ["a", "b", "c"];
4242
console.log(Object.keys(arr)); // ['0', '1', '2']
4343

0 commit comments

Comments
 (0)