From c996ae2b79073ee4b1a7ff5ee7e5fa1d0eef02e6 Mon Sep 17 00:00:00 2001 From: Will <> Date: Wed, 14 Apr 2021 17:23:54 -0700 Subject: [PATCH] Remove inline styles from JS reference --- .../index.html | 444 +++++++++--------- .../en-us/web/javascript/eventloop/index.html | 2 +- .../details_of_the_object_model/index.html | 11 +- .../global_objects/function/apply/index.html | 35 -- .../reference/global_objects/math/index.html | 2 +- .../global_objects/math/log1p/index.html | 13 +- .../global_objects/regexp/exec/index.html | 21 +- .../web/javascript/typed_arrays/index.html | 4 +- 8 files changed, 251 insertions(+), 281 deletions(-) diff --git a/files/en-us/web/javascript/enumerability_and_ownership_of_properties/index.html b/files/en-us/web/javascript/enumerability_and_ownership_of_properties/index.html index 1cfefd670f2b39b..be078677454dc72 100644 --- a/files/en-us/web/javascript/enumerability_and_ownership_of_properties/index.html +++ b/files/en-us/web/javascript/enumerability_and_ownership_of_properties/index.html @@ -7,154 +7,154 @@ ---
Enumerable properties are those properties whose internal enumerable flag is set to true, which is the default for properties created via simple assignment or via a property initializer (properties defined via Object.defineProperty and such default enumerable to false). Enumerable properties show up in for...in loops unless the property's key is a Symbol. Ownership of properties is determined by whether the property belongs to the object directly and not to its prototype chain. Properties of an object can also be retrieved in total. There are a number of built-in means of detecting, iterating/enumerating, and retrieving object properties, with the chart showing below which are available. Some sample code follows which demonstrates how to obtain the missing categories.
+Enumerable properties are those properties whose internal enumerable flag is set to true, which is the default for properties created via simple assignment or via a property initializer. Properties defined via Object.defineProperty and such default enumerable to false.
-Functionality | -Own object | -Own object and its prototype chain | -Prototype chain only | -||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Detection | -
-
|
-
-
|
- Not available without extra code | -||||||||||||||||||||||||||||||||||||||||||||
Retrieval | -
-
|
- Not available without extra code | -Not available without extra code | -||||||||||||||||||||||||||||||||||||||||||||
Iterable | -
-
|
-
-
|
- Not available without extra code | -
+ | Own object | +Own object and prototype chain | +Prototype chain only | +
---|---|---|---|
+ Enumerable + | ++ + + + | +
+
+ (excluding symbols) + |
+ Not available without extra code | +
+ Nonenumerable + | +getOwnPropertyNames , getOwnPropertySymbols – filtered to exclude enumerables using propertyIsEnumerable |
+ Not available without extra code | +Not available without extra code | +
+ Enumerable and Nonenumerable + | ++ + + | +Not available without extra code | +Not available without extra code | +
- | in |
- for..in |
- obj.hasOwnProperty |
- obj.propertyIsEnumerable |
- Object.keys |
- Object.getOwnPropertyNames |
- Object.getOwnPropertyDescriptors |
- Reflect.ownKeys() |
-
---|---|---|---|---|---|---|---|---|
Enumerable | -true | -true | -true | -true | -true | -true | -true | -true | -
Nonenumerable | -true | -false | -true | -false | -false | -true | -true | -true | -
Symbols keys | -true | -false | -true | -true | -false | -false | -true | -true | -
Inherited Enumerable | -true | -true | -false | -false | -false | -false | -false | -false | -
Inherited Nonenumerable | -true | -false | -false | -false | -false | -false | -false | -false | -
Inherited Symbols keys | -true | -false | -false | -false | -false | -false | -false | -false | -
+ | Enumerable | +Nonenumerable | +Symbols keys | +Inherited Enumerable | +Inherited Nonenumerable | +Inherited Symbols keys | +||
in |
+ true | +true | +true | +true | +true | +true | +||
for..in |
+ true | +false | +false | +true | +false | +false | +||
obj.hasOwnProperty |
+ true | +true | +true | +false | +false | +false | +||
obj.propertyIsEnumerable |
+ true | +false | +true | +false | +false | +false | +||
Object.keys |
+ true | +false | +false | +false | +false | +false | +||
Object.getOwnPropertyNames |
+ true | +true | +false | +false | +false | +false | +||
Object.getOwnPropertyDescriptors |
+ true | +true | +true | +false | +false | +false | +||
Reflect.ownKeys() |
+ true | +true | +true | +false | +false | +false | +
The remainder of this chapter uses the employee hierarchy shown in the following figure.
-A simple object hierarchy with the following objects:
- -This shows an object hierarchy with the following objects:
+Employee
has the properties name
(whose value defaults to the empty string) and dept
(whose value defaults to "general").Manager
is based on Employee
. It adds the reports
property (whose value defaults to an empty array, intended to have an array of Employee
objects as its value).SalesPerson
is based on WorkerBee
. It adds the quota
property (whose value defaults to 100). It also overrides the dept
property with the value "sales", indicating that all salespersons are in the same department.Engineer
is based on WorkerBee
. It adds the machine
property (whose value defaults to the empty string) and also overrides the dept
property with the value "engineering".Note: The Object.create()
method used above is relatively new. For alternative methods, please consider one of the following approaches:
Using {{jsxref("Object/proto", "Object.__proto__")}}:
- -Function.prototype.construct = function (aArgs) { - let oNew = {}; - oNew.__proto__ = this.prototype; - this.apply(oNew, aArgs); - return oNew; -}; -- -
Using closures:
- -Function.prototype.construct = function(aArgs) { - let fConstructor = this, fNewConstr = function() { - fConstructor.apply(this, aArgs); - }; - fNewConstr.prototype = fConstructor.prototype; - return new fNewConstr(); -};- -
Using the {{jsxref("Function")}} constructor:
- -Function.prototype.construct = function (aArgs) { - let fNewConstr = new Function(""); - fNewConstr.prototype = this.prototype; - let oNew = new fNewConstr(); - this.apply(oNew, aArgs); - return oNew; -}; --
Example usage:
function MyConstructor() { diff --git a/files/en-us/web/javascript/reference/global_objects/math/index.html b/files/en-us/web/javascript/reference/global_objects/math/index.html index e6a2e083b0bc2a3..083563b4c9953ee 100644 --- a/files/en-us/web/javascript/reference/global_objects/math/index.html +++ b/files/en-us/web/javascript/reference/global_objects/math/index.html @@ -139,7 +139,7 @@-Calculating the heigh
If we want to calculate the height of an equilateral triangle, and we know its side length is 100, we can use the formulae length of the adjacent multiplied by the tangent of the angle is equal to the opposite.
- +In JavaScript, we can do this with the following:
diff --git a/files/en-us/web/javascript/reference/global_objects/math/log1p/index.html b/files/en-us/web/javascript/reference/global_objects/math/log1p/index.html index 7e6d558cc541e55..04517d855bda7ed 100644 --- a/files/en-us/web/javascript/reference/global_objects/math/log1p/index.html +++ b/files/en-us/web/javascript/reference/global_objects/math/log1p/index.html @@ -71,15 +71,12 @@Description
When you calculate log(1 + x), you should get an answer very close to x, if x is small (that's why these are called 'natural' logarithms). If you calculate Math.log(1 + - 1.1111111111e-15) you should get an answer close to 1.1111111111e-15. Instead, you will end up taking the logarithm of 1.00000000000000111022 (the roundoff is in binary so - sometimes it gets ugly), so you - get the answer 1.11022...e-15, with only 3 - correct digits. If, instead, you calculate - Math.log1p(1.1111111111e-15) you will get a + 1.1111111111e-15) you should get an answer close to 1.1111111111e-15. Instead, + you will end up taking the logarithm of 1.00000000000000111022 (the roundoff is in binary so + sometimes it gets ugly), so you get the answer 1.11022...e-15, with only 3 + correct digits. If, instead, you calculate Math.log1p(1.1111111111e-15) you will get a much more accurate answer 1.1111111110999995e-15 with 15 correct digits of - precision (actually 16 in this case).
+ precision (actually 16 in this case).If the value of
diff --git a/files/en-us/web/javascript/reference/global_objects/regexp/exec/index.html b/files/en-us/web/javascript/reference/global_objects/regexp/exec/index.html index 9245421f1dc1636..c322244b912f0da 100644 --- a/files/en-us/web/javascript/reference/global_objects/regexp/exec/index.html +++ b/files/en-us/web/javascript/reference/global_objects/regexp/exec/index.html @@ -67,12 +67,11 @@x
is less than -1, the return value is always {{jsxref("NaN")}}.Description
let result = re.exec('The Quick Brown Fox Jumps Over The Lazy Dog');
The following table shows the results for this script:
+The following table shows the state of result
after running this script:
Object | Property/Index | Description | Example | @@ -80,7 +79,6 @@||
---|---|---|---|---|---|
result |
[0] |
The full string of characters matched | "Quick Brown Fox Jumps" |
@@ -128,8 +126,21 @@ The original string that was matched against. | The Quick Brown Fox Jumps Over The Lazy Dog |
The following table shows the state of re
after running this script:
Property/Index | +Description | +Example | +|||
---|---|---|---|---|---|
re |
lastIndex |
The index at which to start the next match. diff --git a/files/en-us/web/javascript/typed_arrays/index.html b/files/en-us/web/javascript/typed_arrays/index.html index 4007eec172cf5ef..742f062002504bb 100644 --- a/files/en-us/web/javascript/typed_arrays/index.html +++ b/files/en-us/web/javascript/typed_arrays/index.html @@ -97,7 +97,7 @@Typed array views | |||
{{jsxref("Float32Array")}} | -1.2 ×10-38 to 3.4 ×1038 |
+ 1.2 ×10-38 to 3.4 ×1038 |
4 | 32-bit IEEE floating point number (7 significant digits e.g., 1.123456 ) |
unrestricted float |
@@ -105,7 +105,7 @@
{{jsxref("Float64Array")}} | -5.0 ×10-324 to 1.8 ×10308 |
+ 5.0 ×10-324 to 1.8 ×10308 |
8 | 64-bit IEEE floating point number (16 significant digits e.g., 1.123...15 ) |
unrestricted double |