diff --git a/files/en-us/web/javascript/eventloop/index.html b/files/en-us/web/javascript/eventloop/index.html index da568c64927e402..fcbc5b64ba0f98b 100644 --- a/files/en-us/web/javascript/eventloop/index.html +++ b/files/en-us/web/javascript/eventloop/index.html @@ -13,7 +13,7 @@ ---
JavaScript has a concurrency model based on an event loop, which is responsible for executing the code, collecting and processing events, and executing queued sub-tasks. This model is quite different from models in other languages like C and Java.
+JavaScript has a concurrency model based on an event loop, which is responsible for executing the code, collecting and processing events, and executing queued sub-tasks. This model is quite different from models in other languages like C and Java.
Processing each of the items in a collection is a very common operation. JavaScript provides a number of ways of iterating over a collection, from simple {{jsxref("Statements/for","for")}} loops to {{jsxref("Global_Objects/Array/map","map()")}} and {{jsxref("Global_Objects/Array/filter","filter()")}}.
- -Iterators and Generators bring the concept of iteration directly into the core language and provide a mechanism for customizing the behavior of {{jsxref("Statements/for...of","for...of")}} loops.
+Iterators and Generators bring the concept of iteration directly into the core language and provide a mechanism for customizing the behavior of {{jsxref("Statements/for...of","for...of")}} loops.
For details, see also:
diff --git a/files/en-us/web/javascript/guide/numbers_and_dates/index.html b/files/en-us/web/javascript/guide/numbers_and_dates/index.html index 3de3f2d7a524a6b..88b919249db2ed2 100644 --- a/files/en-us/web/javascript/guide/numbers_and_dates/index.html +++ b/files/en-us/web/javascript/guide/numbers_and_dates/index.html @@ -17,7 +17,7 @@ ---This chapter introduces the concepts, objects and functions used to work with and perform calculations using numbers and dates in JavaScript. This includes using numbers written in various bases including decimal, binary, and hexadecimal, as well as the use of the global {{jsxref("Math")}} object to perform a wide variety of mathematical operations on numbers.
+This chapter introduces the concepts, objects and functions used to work with and perform calculations using numbers and dates in JavaScript. This includes using numbers written in various bases including decimal, binary, and hexadecimal, as well as the use of the global {{jsxref("Math")}} object to perform a wide variety of mathematical operations on numbers.
JavaScript (JS) is a lightweight, interpreted, or just-in-time compiled programming language with {{Glossary("First-class Function", "first-class functions")}}. While it is most well-known as the scripting language for Web pages, many non-browser environments also use it, such as {{Glossary("Node.js")}}, Apache CouchDB and Adobe Acrobat. JavaScript is a {{Glossary("Prototype-based programming", "prototype-based")}}, multi-paradigm, single-threaded, dynamic language, supporting object-oriented, imperative, and declarative (e.g. functional programming) styles. Read more about JavaScript.
+JavaScript (JS) is a lightweight, interpreted, or just-in-time compiled programming language with {{Glossary("First-class Function", "first-class functions")}}. While it is most well-known as the scripting language for Web pages, many non-browser environments also use it, such as {{Glossary("Node.js")}}, Apache CouchDB and Adobe Acrobat. JavaScript is a {{Glossary("Prototype-based programming", "prototype-based")}}, multi-paradigm, single-threaded, dynamic language, supporting object-oriented, imperative, and declarative (e.g. functional programming) styles. Read more about JavaScript.
This section is dedicated to the JavaScript language itself, and not the parts that are specific to Web pages or other host environments. For information about {{Glossary("API","API")}} specifics to Web pages, please see Web APIs and {{Glossary("DOM")}}.
diff --git a/files/en-us/web/javascript/reference/classes/static/index.html b/files/en-us/web/javascript/reference/classes/static/index.html index 54ebde2a569b0c1..af5c5476c0c85db 100644 --- a/files/en-us/web/javascript/reference/classes/static/index.html +++ b/files/en-us/web/javascript/reference/classes/static/index.html @@ -10,12 +10,14 @@ ---The The static
keyword defines a
+static
keyword defines a
static method or property for a class. Neither static methods nor static properties
can be called on instances of the class. Instead, they're called on the class
- itself.
Static methods are often utility functions, such as functions to create +or clone objects, whereas static properties are useful for caches, fixed-configuration, +or any other data you don't need to be replicated across instances.
Creates a JavaScript Creates a JavaScript Date
+Date
instance that represents a single moment in time in a platform-independent
- format.Date
objects contain a Number
that represents
+ format.Date
objects contain a Number
that represents
milliseconds since 1 January 1970 UTC.
The The getDay()
method returns the
+getDay()
method returns the
day of the week for the specified date according to local time, where 0 represents
- Sunday.
JavaScript Date
objects represent a single moment in time in a platform-independent format. Date
objects contain a Number
that represents milliseconds since 1 January 1970 UTC.
JavaScript Date
objects represent a single moment in time in a platform-independent format. Date
objects contain a Number
that represents milliseconds since 1 January 1970 UTC.
TC39 is working on Temporal, a new Date/Time API. Read more about it on the Igalia blog. It is not yet ready for production use!
diff --git a/files/en-us/web/javascript/reference/global_objects/map/index.html b/files/en-us/web/javascript/reference/global_objects/map/index.html index 12a2de2fc6c3848..a2bda6e2b2bb8c7 100644 --- a/files/en-us/web/javascript/reference/global_objects/map/index.html +++ b/files/en-us/web/javascript/reference/global_objects/map/index.html @@ -10,8 +10,8 @@ ---The Map
object holds key-value
- pairs and remembers the original insertion order of the keys. Any value (both
+
The Map
object holds key-value
+ pairs and remembers the original insertion order of the keys. Any value (both
objects and {{glossary("Primitive", "primitive values")}}) may be used as either a key
or a value.
The Math.abs()
function returns
- the absolute value of a number, that is
The Math.abs()
function returns
+ the absolute value of a number. That is, it returns x
if x
+ is positive or zero, and the negation of x
if x
is negative.
The The Math.cos()
static function
+Math.cos()
static function
returns the {{interwiki("wikipedia", "cosine")}} of the specified angle, which must be
- specified in {{interwiki("wikipedia", "radians")}}. This value is
The The Number.isFinite()
method
+Number.isFinite()
method
determines whether the passed value is a finite number — that is, it checks that the
type of a given value is {{jsxref("Number")}}, and the number is neither positive
- {{jsxref("Infinity")}}, negative Infinity
, nor {{jsxref("NaN")}}.
Infinity
, nor {{jsxref("NaN")}}.
The RangeError
object indicates an error when a value is not in the set or range of allowed values.
The RangeError
object indicates an error when a value is not in the set or range of allowed values.
The RangeError()
constructor
- creates an error when a value is not in the set or range of allowed values.
-
The RangeError()
constructor creates an error
+ when a value is not in the set or range of allowed values.
The static
+ The static
Reflect.preventExtensions()
method prevents new
properties from ever being added to an object (i.e., prevents future extensions to the
- object).
The static
+ The static
Reflect.setPrototypeOf()
method is the same method as
{{jsxref("Object.setPrototypeOf()")}}, except for its return type. It sets the
prototype (i.e., the internal [[Prototype]]
property) of a specified
object to another object or to {{jsxref("null")}}, and returns true
if
- the operation was successful, or false
otherwise
false
otherwise.
The The padStart()
method pads the
+padStart()
method pads the
current string with another string (multiple times, if needed) until the resulting
- string reaches the given length.
The static The static String.raw()
method
+String.raw()
method
is a tag function of template literals.
This is similar to the r
prefix in Python, or the @
prefix in C# for string literals. (But it is not identical; see explanations
in this issue.)
It's used to get the raw string form of template literals, that is, substitutions (e.g.
- ${foo}
) are processed, but escapes (e.g. \n
) are not.
${foo}
) are processed, but escapes (e.g. \n
) are not.
The The replace()
method returns a
+replace()
method returns a
new string with some or all matches of a pattern
replaced by a
- replacement
.pattern
can be a string or a
+ replacement
. The pattern
can be a string or a
{{jsxref("RegExp")}}, and the replacement
can be a string or a function to
be called for each match. If pattern
is a string, only the first occurrence
will be replaced.
The The replaceAll()
method returns
+replaceAll()
method returns
a new string with all matches of a pattern
replaced by a
- replacement
.pattern
can be a string or a
+ replacement
. The pattern
can be a string or a
{{jsxref("RegExp")}}, and the replacement
can be a string or a function to
be called for each match.
The conditional (ternary) operator is the
+ The conditional (ternary) operator is the
only JavaScript operator that takes three operands: a condition followed by a
question mark (?
), then an expression to execute if the condition is
{{Glossary("truthy")}} followed by a colon (:
), and finally the
- expression to execute if the condition is {{Glossary("falsy")}}.if
statement.
The optional chaining operator (?.
)
- permits reading the value of a property located deep within a chain of connected objects
- without having to expressly validate that each reference in the chain is valid. The ?.
operator functions similarly to the
+ enables you to read the value of a property located deep within a chain of connected objects
+ without having to check that each reference in the chain is valid.
The ?.
operator is like the
.
chaining operator, except that instead of causing an error if a
reference is nullish ({{JSxRef("null")}} or
{{JSxRef("undefined")}}), the expression short-circuits with a return value of
- undefined
. When used with function calls, it returns
+ undefined
. When used with function calls, it returns
undefined
if the given function does not exist.
This results in shorter and simpler expressions when accessing chained properties when diff --git a/files/en-us/web/javascript/reference/statements/async_function/index.html b/files/en-us/web/javascript/reference/statements/async_function/index.html index 4737441d246e9bc..28428895c61b5b7 100644 --- a/files/en-us/web/javascript/reference/statements/async_function/index.html +++ b/files/en-us/web/javascript/reference/statements/async_function/index.html @@ -10,8 +10,7 @@ ---
An async function is a function declared with the async
keyword, and the await
keyword is permitted within them. The async
and await
keywords enable asynchronous, promise-based behavior to be written in a cleaner style, avoiding the need to explicitly configure promise chains.
-
An async function is a function declared with the async
keyword, and the await
keyword is permitted within them. The async
and await
keywords enable asynchronous, promise-based behavior to be written in a cleaner style, avoiding the need to explicitly configure promise chains.
Async functions may also be defined {{jsxref("Operators/async_function", "as expressions", "", 1)}}.
diff --git a/files/en-us/web/javascript/reference/statements/import/index.html b/files/en-us/web/javascript/reference/statements/import/index.html index 14b2fdb3afcae23..7a4099a6d2a368f 100644 --- a/files/en-us/web/javascript/reference/statements/import/index.html +++ b/files/en-us/web/javascript/reference/statements/import/index.html @@ -13,10 +13,11 @@ ---The static The static import
statement is
+import
statement is
used to import read only live bindings which are exported by
- another module.
Imported modules are in {{JSxRef("Strict_mode","strict mode")}}
whether you declare them as such or not. The import
statement cannot be
used in embedded scripts unless such script has a type="module"
. Bindings
imported are called live bindings because they are updated by the module that exported
diff --git a/files/en-us/web/javascript/typed_arrays/index.html b/files/en-us/web/javascript/typed_arrays/index.html
index 11bd8333febef57..4007eec172cf5ef 100644
--- a/files/en-us/web/javascript/typed_arrays/index.html
+++ b/files/en-us/web/javascript/typed_arrays/index.html
@@ -7,9 +7,9 @@
---
JavaScript typed arrays are array-like objects that provide a mechanism for reading and writing raw binary data in memory buffers. As you may already know, {{jsxref("Array")}} objects grow and shrink dynamically and can have any JavaScript value. JavaScript engines perform optimizations so that these arrays are fast.
+JavaScript typed arrays are array-like objects that provide a mechanism for reading and writing raw binary data in memory buffers.
-However, as web applications become more and more powerful, adding features such as audio and video manipulation, access to raw data using WebSockets, and so forth, it has become clear that there are times when it would be helpful for JavaScript code to be able to quickly and easily manipulate raw binary data. This is where typed arrays come in. Each entry in a JavaScript typed array is a raw binary value in one of a number of supported formats, from 8-bit integers to 64-bit floating-point numbers.
+{{jsxref("Array")}} objects grow and shrink dynamically and can have any JavaScript value. JavaScript engines perform optimizations so that these arrays are fast. However, as web applications become more and more powerful, adding features such as audio and video manipulation, access to raw data using WebSockets, and so forth, it has become clear that there are times when it would be helpful for JavaScript code to be able to quickly and easily manipulate raw binary data. This is where typed arrays come in. Each entry in a JavaScript typed array is a raw binary value in one of a number of supported formats, from 8-bit integers to 64-bit floating-point numbers.
However, typed arrays are not to be confused with normal arrays, as calling {{jsxref("Array.isArray()")}} on a typed array returns false
. Moreover, not all methods available for normal arrays are supported by typed arrays (e.g. push and pop).