Skip to content

Commit

Permalink
Fix typos and pseudo-typos 4 (#36245)
Browse files Browse the repository at this point in the history
* Fix typos and pseudo-typos 4

* Revert arc h function changes
  • Loading branch information
Josh-Cena authored Oct 28, 2024
1 parent a80f7ef commit 2c76277
Show file tree
Hide file tree
Showing 40 changed files with 142 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ Note that this is not the most efficient algorithm for all cases, but useful for

```js
const SimplePropertyRetriever = {
getOwnEnumerables(obj) {
getOwnEnumProps(obj) {
return this._getPropertyNames(obj, true, false, this._enumerable);
// Or could use for...in filtered with Object.hasOwn or just this: return Object.keys(obj);
},
getOwnNonenumerables(obj) {
getOwnNonEnumProps(obj) {
return this._getPropertyNames(obj, true, false, this._notEnumerable);
},
getOwnEnumerablesAndNonenumerables(obj) {
getOwnProps(obj) {
return this._getPropertyNames(
obj,
true,
Expand All @@ -71,28 +71,28 @@ const SimplePropertyRetriever = {
);
// Or just use: return Object.getOwnPropertyNames(obj);
},
getPrototypeEnumerables(obj) {
getPrototypeEnumProps(obj) {
return this._getPropertyNames(obj, false, true, this._enumerable);
},
getPrototypeNonenumerables(obj) {
getPrototypeNonEnumProps(obj) {
return this._getPropertyNames(obj, false, true, this._notEnumerable);
},
getPrototypeEnumerablesAndNonenumerables(obj) {
getPrototypeProps(obj) {
return this._getPropertyNames(
obj,
false,
true,
this._enumerableAndNotEnumerable,
);
},
getOwnAndPrototypeEnumerables(obj) {
getOwnAndPrototypeEnumProps(obj) {
return this._getPropertyNames(obj, true, true, this._enumerable);
// Or could use unfiltered for...in
},
getOwnAndPrototypeNonenumerables(obj) {
getOwnAndPrototypeNonEnumProps(obj) {
return this._getPropertyNames(obj, true, true, this._notEnumerable);
},
getOwnAndPrototypeEnumerablesAndNonenumerables(obj) {
getOwnAndPrototypeEnumAndNonEnumProps(obj) {
return this._getPropertyNames(
obj,
true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,8 @@ The shorthand assignment operator `+=` can also be used to concatenate strings.
For example,
```js
let mystring = "alpha";
mystring += "bet"; // evaluates to "alphabet" and assigns this value to mystring.
let myString = "alpha";
myString += "bet"; // evaluates to "alphabet" and assigns this value to myString.
```
## Conditional (ternary) operator
Expand Down Expand Up @@ -1024,9 +1024,9 @@ const myString = new String("coral");
"length" in myString; // returns true

// Custom objects
const mycar = { make: "Honda", model: "Accord", year: 1998 };
"make" in mycar; // returns true
"model" in mycar; // returns true
const myCar = { make: "Honda", model: "Accord", year: 1998 };
"make" in myCar; // returns true
"model" in myCar; // returns true
```
### instanceof
Expand Down Expand Up @@ -1070,8 +1070,8 @@ this.propertyName;
Suppose a function called `validate` validates an object's `value` property, given the object and the high and low values:
```js
function validate(obj, lowval, hival) {
if (obj.value < lowval || obj.value > hival) {
function validate(obj, lowVal, highVal) {
if (obj.value < lowVal || obj.value > highVal) {
console.log("Invalid Value!");
}
}
Expand Down
8 changes: 4 additions & 4 deletions files/en-us/web/javascript/guide/functions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ function myFunc(theObject) {
theObject.make = "Toyota";
}

const mycar = {
const myCar = {
make: "Honda",
model: "Accord",
year: 1998,
};

console.log(mycar.make); // "Honda"
myFunc(mycar);
console.log(mycar.make); // "Toyota"
console.log(myCar.make); // "Honda"
myFunc(myCar);
console.log(myCar.make); // "Toyota"
```

When you pass an array as a parameter, if the function changes any of the array's values, that change is visible outside the function, as shown in the following example:
Expand Down
24 changes: 12 additions & 12 deletions files/en-us/web/javascript/guide/loops_and_iteration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,30 +331,30 @@ If you comment out the `continue;`, the loop would run till the end and you woul

### Example 2

A statement labeled `checkiandj` contains a statement labeled
`checkj`. If `continue` is encountered, the program
terminates the current iteration of `checkj` and begins the next
iteration. Each time `continue` is encountered, `checkj`
A statement labeled `checkIandJ` contains a statement labeled
`checkJ`. If `continue` is encountered, the program
terminates the current iteration of `checkJ` and begins the next
iteration. Each time `continue` is encountered, `checkJ`
reiterates until its condition returns `false`. When `false` is
returned, the remainder of the `checkiandj` statement is completed,
and `checkiandj` reiterates until its condition returns
returned, the remainder of the `checkIandJ` statement is completed,
and `checkIandJ` reiterates until its condition returns
`false`. When `false` is returned, the program continues at the
statement following `checkiandj`.
statement following `checkIandJ`.

If `continue` had a label of `checkiandj`, the program
would continue at the top of the `checkiandj` statement.
If `continue` had a label of `checkIandJ`, the program
would continue at the top of the `checkIandJ` statement.

```js
let i = 0;
let j = 10;
checkiandj: while (i < 4) {
checkIandJ: while (i < 4) {
console.log(i);
i += 1;
checkj: while (j > 4) {
checkJ: while (j > 4) {
console.log(j);
j -= 1;
if (j % 2 === 0) {
continue checkj;
continue checkJ;
}
console.log(j, "is odd.");
}
Expand Down
10 changes: 5 additions & 5 deletions files/en-us/web/javascript/guide/modules/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,18 +312,18 @@ The example below demonstrates this.
```json
{
"imports": {
"coolmodule": "/node_modules/coolmodule/index.js"
"cool-module": "/node_modules/cool-module/index.js"
},
"scopes": {
"/node_modules/dependency/": {
"coolmodule": "/node_modules/some/other/location/coolmodule/index.js"
"cool-module": "/node_modules/some/other/location/cool-module/index.js"
}
}
}
```
With this mapping, if a script with an URL that contains `/node_modules/dependency/` imports `coolmodule`, the version in `/node_modules/some/other/location/coolmodule/index.js` will be used.
The map in `imports` is used as a fallback if there is no matching scope in the scoped map, or the matching scopes don't contain a matching specifier. For example, if `coolmodule` is imported from a script with a non-matching scope path, then the module specifier map in `imports` will be used instead, mapping to the version in `/node_modules/coolmodule/index.js`.
With this mapping, if a script with an URL that contains `/node_modules/dependency/` imports `cool-module`, the version in `/node_modules/some/other/location/cool-module/index.js` will be used.
The map in `imports` is used as a fallback if there is no matching scope in the scoped map, or the matching scopes don't contain a matching specifier. For example, if `cool-module` is imported from a script with a non-matching scope path, then the module specifier map in `imports` will be used instead, mapping to the version in `/node_modules/cool-module/index.js`.
Note that the path used to select a scope does not affect how the address is resolved.
The value in the mapped path does not have to match the scopes path, and relative paths are still resolved to the base URL of the script that contains the import map.
Expand Down Expand Up @@ -405,7 +405,7 @@ You can only use `import` and `export` statements inside modules, not regular sc
You should generally define all your modules in separate files. Modules declared inline in HTML can only import other modules, but anything they export will not be accessible by other modules (because they don't have a URL).
> [!NOTE]
> Modules and their dependencies can be preloaded by specifying them in [`<link>`](/en-US/docs/Web/HTML/Element/link) elements with [`rel="modulepreloaded"`](/en-US/docs/Web/HTML/Attributes/rel/modulepreload).
> Modules and their dependencies can be preloaded by specifying them in [`<link>`](/en-US/docs/Web/HTML/Element/link) elements with [`rel="modulepreload"`](/en-US/docs/Web/HTML/Attributes/rel/modulepreload).
> This can significantly reduce load time when the modules are used.
## Other differences between modules and classic scripts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ Assertions include boundaries, which indicate the beginnings and endings of line

### General boundary-type overview example

<!-- cSpell:ignore greon -->

```js
// Using Regex boundaries to fix buggy string.
buggyMultiline = `tey, ihe light-greon apple
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,7 @@ This page provides an overall cheat sheet of all the capabilities of `RegExp` sy
<code><em>x</em>{<em>n</em>,<em>m</em>}</code>
</td>
<td>
<!-- cSpell:ignore cndy -->
<p>
Where "n" and "m" are non-negative integers and <code>m >= n</code>,
matches at least "n" and at most "m" occurrences of the preceding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ const personList = `First_Name: John, Last_Name: Doe
First_Name: Jane, Last_Name: Smith`;

const regexpNames =
/First_Name: (?<firstname>\w+), Last_Name: (?<lastname>\w+)/g;
/First_Name: (?<firstName>\w+), Last_Name: (?<lastName>\w+)/g;
for (const match of personList.matchAll(regexpNames)) {
console.log(`Hello ${match.groups.firstname} ${match.groups.lastname}`);
console.log(`Hello ${match.groups.firstName} ${match.groups.lastName}`);
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ Quantifiers indicate numbers of characters or expressions to match.
<code><em>x</em>{<em>n</em>,<em>m</em>}</code>
</td>
<td>
<!-- cSpell:ignore cndy -->
<p>
Where "n" and "m" are non-negative integers and <code>m >= n</code>,
matches at least "n" and at most "m" occurrences of the preceding
Expand Down
34 changes: 17 additions & 17 deletions files/en-us/web/javascript/guide/working_with_objects/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ This statement creates `myCar` and assigns it the specified values for its prope
You can create any number of `Car` objects by calls to `new`. For example,

```js
const kenscar = new Car("Nissan", "300ZX", 1992);
const vpgscar = new Car("Mazda", "Miata", 1990);
const randCar = new Car("Nissan", "300ZX", 1992);
const kenCar = new Car("Mazda", "Miata", 1990);
```

An object can have a property that is itself another object. For example, suppose you define an object called `Person` as follows:
Expand Down Expand Up @@ -328,14 +328,14 @@ For more information, see [Enumerability and ownership of properties](/en-US/doc
You can remove a non-inherited property using the [`delete`](/en-US/docs/Web/JavaScript/Reference/Operators/delete) operator. The following code shows how to remove a property.

```js
// Creates a new object, myobj, with two properties, a and b.
const myobj = new Object();
myobj.a = 5;
myobj.b = 12;
// Creates a new object, myObj, with two properties, a and b.
const myObj = new Object();
myObj.a = 5;
myObj.b = 12;

// Removes the a property, leaving myobj with only the b property.
delete myobj.a;
console.log("a" in myobj); // false
// Removes the a property, leaving myObj with only the b property.
delete myObj.a;
console.log("a" in myObj); // false
```

## Inheritance
Expand Down Expand Up @@ -489,23 +489,23 @@ In JavaScript, objects are a reference type. Two distinct objects are never equa
```js
// Two variables, two distinct objects with the same properties
const fruit = { name: "apple" };
const fruitbear = { name: "apple" };
const anotherFruit = { name: "apple" };

fruit == fruitbear; // return false
fruit === fruitbear; // return false
fruit == anotherFruit; // return false
fruit === anotherFruit; // return false
```

```js
// Two variables, a single object
const fruit = { name: "apple" };
const fruitbear = fruit; // Assign fruit object reference to fruitbear
const anotherFruit = fruit; // Assign fruit object reference to anotherFruit

// Here fruit and fruitbear are pointing to same object
fruit == fruitbear; // return true
fruit === fruitbear; // return true
// Here fruit and anotherFruit are pointing to same object
fruit == anotherFruit; // return true
fruit === anotherFruit; // return true

fruit.name = "grape";
console.log(fruitbear); // { name: "grape" }; not { name: "apple" }
console.log(anotherFruit); // { name: "grape" }; not { name: "apple" }
```

For more information about comparison operators, see [equality operators](/en-US/docs/Web/JavaScript/Reference/Operators#equality_operators).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ const o = { a: 1 };
// Object.prototype has null as its [[Prototype]].
// o ---> Object.prototype ---> null

const b = ["yo", "whadup", "?"];
const b = ["yo", "sup", "?"];
// Arrays inherit from Array.prototype
// (which has methods indexOf, forEach, etc.)
// The prototype chain looks like:
Expand Down
10 changes: 5 additions & 5 deletions files/en-us/web/javascript/memory_management/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ In order to not bother the programmer with allocations, JavaScript will automati

```js
const n = 123; // allocates memory for a number
const s = "azerty"; // allocates memory for a string
const s = "string"; // allocates memory for a string

const o = {
a: 1,
Expand All @@ -35,7 +35,7 @@ const o = {

// (like object) allocates memory for the array and
// contained values
const a = [1, null, "abra"];
const a = [1, null, "str2"];

function f(a) {
return a + 2;
Expand Down Expand Up @@ -64,14 +64,14 @@ const e = document.createElement("div"); // allocates a DOM element
Some methods allocate new values or objects:

```js
const s = "azerty";
const s = "string";
const s2 = s.substr(0, 3); // s2 is a new string
// Since strings are immutable values,
// JavaScript may decide to not allocate memory,
// but just store the [0, 3] range.

const a = ["ouais ouais", "nan nan"];
const a2 = ["generation", "nan nan"];
const a = ["yeah yeah", "no no"];
const a2 = ["generation", "no no"];
const a3 = a.concat(a2);
// new array with 4 elements being
// the concatenation of a and a2 elements.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ const [] = nonIterable1;
### Array destructuring a non-iterable

```js example-bad
const myobj = { arrayOrObjProp1: {}, arrayOrObjProp2: [42] };
const myObj = { arrayOrObjProp1: {}, arrayOrObjProp2: [42] };

const {
arrayOrObjProp1: [value1],
arrayOrObjProp2: [value2],
} = myobj; // TypeError: object is not iterable
} = myObj; // TypeError: object is not iterable

console.log(value1, value2);
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ function Car(make, model, year) {
}
```

Now you can create an object called `mycar` as follows:
Now you can create an object called `myCar` as follows:

```js
const mycar = new Car("Eagle", "Talon TSi", 1993);
const myCar = new Car("Eagle", "Talon TSi", 1993);
```

### In Promises
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function checkAvailability(arr, val) {
return arr.some((arrVal) => val === arrVal);
}

checkAvailability(fruits, "kela"); // false
checkAvailability(fruits, "grapefruit"); // false
checkAvailability(fruits, "banana"); // true
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ Special cases:
const previousMaxSafe = BigInt(Number.MAX_SAFE_INTEGER); // 9007199254740991n
const maxPlusOne = previousMaxSafe + 1n; // 9007199254740992n
const theFuture = previousMaxSafe + 2n; // 9007199254740993n, this works now!
const multi = previousMaxSafe * 2n; // 18014398509481982n
const subtr = multi - 10n; // 18014398509481972n
const mod = multi % 10n; // 2n
const prod = previousMaxSafe * 2n; // 18014398509481982n
const diff = prod - 10n; // 18014398509481972n
const mod = prod % 10n; // 2n
const bigN = 2n ** 54n; // 18014398509481984n
bigN * -1n; // -18014398509481984n
const expected = 4n / 2n; // 2n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Besides the generic `Error` constructor, there are other core error constructors
- `Error.stackTraceLimit` {{non-standard_inline}}
- : A non-standard V8 numerical property that limits how many stack frames to include in an error stacktrace.
- `Error.prepareStackTrace()` {{non-standard_inline}} {{optional_inline}}
- : A non-standard V8 function that, if provided by usercode, is called by the V8 JavaScript engine for thrown exceptions, allowing the user to provide custom formatting for stacktraces.
- : A non-standard V8 function that, if provided by user code, is called by the V8 JavaScript engine for thrown exceptions, allowing the user to provide custom formatting for stacktraces.

## Instance properties

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function a() {
b(3, 4, "\n\n", undefined, {});
}
try {
a("first call, firstarg");
a("first call, first arg");
} catch (e) {
document.getElementById("output").textContent = e.stack;
}
Expand Down
Loading

0 comments on commit 2c76277

Please sign in to comment.