From 3b80812a1d4f68e57f35fca763f50bf3e5dfe997 Mon Sep 17 00:00:00 2001
From: Peter Bengtsson Syntax
-var isCollapsed = range.collapsed
+var isCollapsed = range.collapsed
Value
diff --git a/files/en-us/web/api/abstractrange/endcontainer/index.html b/files/en-us/web/api/abstractrange/endcontainer/index.html
index 943315fdfd0ff04..492e98c5798e317 100644
--- a/files/en-us/web/api/abstractrange/endcontainer/index.html
+++ b/files/en-us/web/api/abstractrange/endcontainer/index.html
@@ -22,7 +22,7 @@
Syntax
-var endNode = range.endContainer
+
var endNode = range.endContainer
Value
diff --git a/files/en-us/web/api/abstractrange/endoffset/index.html b/files/en-us/web/api/abstractrange/endoffset/index.html
index dbf057c903300c3..a27a6c49376b9ad 100644
--- a/files/en-us/web/api/abstractrange/endoffset/index.html
+++ b/files/en-us/web/api/abstractrange/endoffset/index.html
@@ -20,7 +20,7 @@
Syntax
-var endOffset = range.endOffset;
+var endOffset = range.endOffset;
Value
diff --git a/files/en-us/web/api/abstractrange/startcontainer/index.html b/files/en-us/web/api/abstractrange/startcontainer/index.html
index e4e8640306e888b..35bb0a4e68245ef 100644
--- a/files/en-us/web/api/abstractrange/startcontainer/index.html
+++ b/files/en-us/web/api/abstractrange/startcontainer/index.html
@@ -19,7 +19,7 @@
Syntax
-var startNode = range.startContainer
+
var startNode = range.startContainer
Value
diff --git a/files/en-us/web/api/abstractrange/startoffset/index.html b/files/en-us/web/api/abstractrange/startoffset/index.html
index ec2d68f25c157df..fb3560b106df3fa 100644
--- a/files/en-us/web/api/abstractrange/startoffset/index.html
+++ b/files/en-us/web/api/abstractrange/startoffset/index.html
@@ -19,7 +19,7 @@
Syntax
-var startOffset = range.startOffset
+
var startOffset = range.startOffset
Value
diff --git a/files/en-us/web/api/beforeinstallpromptevent/prompt/index.html b/files/en-us/web/api/beforeinstallpromptevent/prompt/index.html
index bdafc04b5ca2655..38fb8717433181e 100644
--- a/files/en-us/web/api/beforeinstallpromptevent/prompt/index.html
+++ b/files/en-us/web/api/beforeinstallpromptevent/prompt/index.html
@@ -15,7 +15,7 @@
Syntax
-BeforeInstallPromptEvent.prompt()
+BeforeInstallPromptEvent.prompt()
Parameters
diff --git a/files/en-us/web/api/clipboard/read/index.html b/files/en-us/web/api/clipboard/read/index.html
index ef78e4afd7857d8..bcbfd33adc59abf 100644
--- a/files/en-us/web/api/clipboard/read/index.html
+++ b/files/en-us/web/api/clipboard/read/index.html
@@ -39,7 +39,7 @@
Syntax
var promise = navigator.clipboard.read();
+ class="brush: js">var promise = navigator.clipboard.read();Parameters
@@ -59,7 +59,7 @@ Example
image, an error message is presented. Otherwise, an image element referred to using the
variable imgElem
has its source replaced with the clipboard's contents.
// First, ask the Permissions API if we have some kind of access to +// First, ask the Permissions API if we have some kind of access to // the "clipboard-read" feature. navigator.permissions.query({name: "clipboard-read"}).then(result => { diff --git a/files/en-us/web/api/clipboard/readtext/index.html b/files/en-us/web/api/clipboard/readtext/index.html index 9b385a6c6041556..07c19f2c8ba1d2b 100644 --- a/files/en-us/web/api/clipboard/readtext/index.html +++ b/files/en-us/web/api/clipboard/readtext/index.html @@ -29,7 +29,7 @@Syntax
var promise = navigator.clipboard.readText()+ class="brush: js">var promise = navigator.clipboard.readText()Parameters
@@ -51,7 +51,7 @@Example
This example retrieves the textual contents of the clipboard and inserts the returned text into an element's contents.
-navigator.clipboard.readText().then( +navigator.clipboard.readText().then( clipText => document.getElementById("outbox").innerText = clipText);Specifications
diff --git a/files/en-us/web/api/clipboard/write/index.html b/files/en-us/web/api/clipboard/write/index.html index cfa0b52e0aafedd..c74fcb5775a61e3 100644 --- a/files/en-us/web/api/clipboard/write/index.html +++ b/files/en-us/web/api/clipboard/write/index.html @@ -36,7 +36,7 @@Syntax
var promise = navigator.clipboard.write(data)+ class="brush: js">var promise = navigator.clipboard.write(data)Parameters
@@ -57,7 +57,7 @@Example
This example function replaces the current contents of the clipboard with a specified string.
-function setClipboard(text) { +function setClipboard(text) { let data = [new ClipboardItem({ "text/plain": text })]; navigator.clipboard.write(data).then(function() { @@ -78,7 +78,7 @@Example
Example of copying canvas contents to the clipboard
-function copyCanvasContentsToClipboard(canvas, onDone, onError) { +function copyCanvasContentsToClipboard(canvas, onDone, onError) { canvas.toBlob(function (blob) { let data = [new ClipboardItem({ [blob.type]: blob })]; diff --git a/files/en-us/web/api/clipboard/writetext/index.html b/files/en-us/web/api/clipboard/writetext/index.html index 50059294f27b97c..033a770857f71c8 100644 --- a/files/en-us/web/api/clipboard/writetext/index.html +++ b/files/en-us/web/api/clipboard/writetext/index.html @@ -37,7 +37,7 @@Syntax
var promise = navigator.clipboard.writeText(newClipText)+ class="brush: js">var promise = navigator.clipboard.writeText(newClipText)Parameters
@@ -56,7 +56,7 @@Example
This example sets the clipboard's contents to the string "<empty clipboard>".
-navigator.clipboard.writeText("<empty clipboard>").then(function() { +navigator.clipboard.writeText("<empty clipboard>").then(function() { /* clipboard successfully set */ }, function() { /* clipboard write failed */ diff --git a/files/en-us/web/api/console/assert/index.html b/files/en-us/web/api/console/assert/index.html index bd9d450e1c8b1a2..78206a3dbed34bc 100644 --- a/files/en-us/web/api/console/assert/index.html +++ b/files/en-us/web/api/console/assert/index.html @@ -19,7 +19,7 @@Syntax
-console.assert(assertion, obj1 [, obj2, ..., objN]); +console.assert(assertion, obj1 [, obj2, ..., objN]); console.assert(assertion, msg [, subst1, ..., substN]); // C-like message formattingdiff --git a/files/en-us/web/api/console/clear/index.html b/files/en-us/web/api/console/clear/index.html index c9b110e2844b127..39c087ebb02b6c4 100644 --- a/files/en-us/web/api/console/clear/index.html +++ b/files/en-us/web/api/console/clear/index.html @@ -16,7 +16,7 @@Syntax
-console.clear(); +console.clear();Specifications
diff --git a/files/en-us/web/api/console/count/index.html b/files/en-us/web/api/console/count/index.html index c1a5a291beab367..5c2cddb100fc6c1 100644 --- a/files/en-us/web/api/console/count/index.html +++ b/files/en-us/web/api/console/count/index.html @@ -19,7 +19,7 @@Syntax
-console.count([label]);+console.count([label]);Parameters
diff --git a/files/en-us/web/api/console/countreset/index.html b/files/en-us/web/api/console/countreset/index.html index b3db0b9acdfeb57..bc3a5837cab4ae3 100644 --- a/files/en-us/web/api/console/countreset/index.html +++ b/files/en-us/web/api/console/countreset/index.html @@ -20,7 +20,7 @@Syntax
-console.countReset([label]); +console.countReset([label]);Parameters
diff --git a/files/en-us/web/api/console/debug/index.html b/files/en-us/web/api/console/debug/index.html index 7b7abab95289578..b5d7941a6f38068 100644 --- a/files/en-us/web/api/console/debug/index.html +++ b/files/en-us/web/api/console/debug/index.html @@ -26,7 +26,7 @@Syntax
-console.debug(obj1 [, obj2, ..., objN]); +console.debug(obj1 [, obj2, ..., objN]); console.debug(msg [, subst1, ..., substN]);diff --git a/files/en-us/web/api/console/dir/index.html b/files/en-us/web/api/console/dir/index.html index d3da64e2d75ce03..58b50f23262630f 100644 --- a/files/en-us/web/api/console/dir/index.html +++ b/files/en-us/web/api/console/dir/index.html @@ -29,7 +29,7 @@Syntax
-console.dir(object); +console.dir(object);Parameters
diff --git a/files/en-us/web/api/console/dirxml/index.html b/files/en-us/web/api/console/dirxml/index.html index 73bf46f9328f82a..3344892dfb1c2ad 100644 --- a/files/en-us/web/api/console/dirxml/index.html +++ b/files/en-us/web/api/console/dirxml/index.html @@ -18,7 +18,7 @@Syntax
-console.dirxml(object); +console.dirxml(object);Parameters
diff --git a/files/en-us/web/api/console/error/index.html b/files/en-us/web/api/console/error/index.html index 281c342b51f20b8..004f9dcb11d3f55 100644 --- a/files/en-us/web/api/console/error/index.html +++ b/files/en-us/web/api/console/error/index.html @@ -17,7 +17,7 @@Syntax
-console.error(obj1 [, obj2, ..., objN]); +console.error(obj1 [, obj2, ..., objN]); console.error(msg [, subst1, ..., substN]);diff --git a/files/en-us/web/api/console/group/index.html b/files/en-us/web/api/console/group/index.html index f4bf39c626afde7..3de01dc7b8ccc34 100644 --- a/files/en-us/web/api/console/group/index.html +++ b/files/en-us/web/api/console/group/index.html @@ -19,7 +19,7 @@Syntax
-console.group([label]); +console.group([label]);Parameters
diff --git a/files/en-us/web/api/console/groupcollapsed/index.html b/files/en-us/web/api/console/groupcollapsed/index.html index 9a7932856f09a30..06cf349c0dbe19d 100644 --- a/files/en-us/web/api/console/groupcollapsed/index.html +++ b/files/en-us/web/api/console/groupcollapsed/index.html @@ -27,7 +27,7 @@Syntax
-console.groupCollapsed([label]); +console.groupCollapsed([label]);Parameters
diff --git a/files/en-us/web/api/console/groupend/index.html b/files/en-us/web/api/console/groupend/index.html index 8538872bee9a7c0..66f0f62054082b2 100644 --- a/files/en-us/web/api/console/groupend/index.html +++ b/files/en-us/web/api/console/groupend/index.html @@ -21,7 +21,7 @@Syntax
-console.groupEnd(); +console.groupEnd();Parameters
diff --git a/files/en-us/web/api/console/index.html b/files/en-us/web/api/console/index.html index 96725e1ca240e66..022449390db3c4c 100644 --- a/files/en-us/web/api/console/index.html +++ b/files/en-us/web/api/console/index.html @@ -15,7 +15,7 @@The
-console
object can be accessed from any global object. {{domxref("Window")}} on browsing scopes and {{domxref("WorkerGlobalScope")}} as specific variants in workers via the property console. It's exposed as {{domxref("Window.console")}}, and can be referenced asconsole
. For example:console.log("Failed to open the specified link")+console.log("Failed to open the specified link")This page documents the {{anch("Methods")}} available on the
@@ -88,25 +88,25 @@console
object and gives a few {{anch("Usage")}} examples.Outputting a single object
The simplest way to use the logging methods is to output a single object:
-var someObject = { str: "Some text", id: 5 }; +var someObject = { str: "Some text", id: 5 }; console.log(someObject);The output looks something like this:
-[09:27:13.475] ({str:"Some text", id:5})+[09:27:13.475] ({str:"Some text", id:5})Outputting multiple objects
You can also output multiple objects by listing them when calling the logging method, like this:
-var car = "Dodge Charger"; +var car = "Dodge Charger"; var someObject = { str: "Some text", id: 5 }; console.info("My first car was a", car, ". The object is:", someObject);This output will look like this:
-[09:28:22.711] My first car was a Dodge Charger . The object is: ({str:"Some text", id:5}) +[09:28:22.711] My first car was a Dodge Charger . The object is: ({str:"Some text", id:5})Using string substitutions
@@ -130,14 +130,14 @@Using string substitutions
Each of these pulls the next argument after the format string off the parameter list. For example:
-for (var i=0; i<5; i++) { +for (var i=0; i<5; i++) { console.log("Hello, %s. You've called me %d times.", "Bob", i+1); }The output looks like this:
-[13:14:13.481] Hello, Bob. You've called me 1 times. +[13:14:13.481] Hello, Bob. You've called me 1 times. [13:14:13.483] Hello, Bob. You've called me 2 times. [13:14:13.485] Hello, Bob. You've called me 3 times. [13:14:13.487] Hello, Bob. You've called me 4 times. @@ -148,7 +148,7 @@Styling console output
You can use the
-%c
directive to apply a CSS style to console output:console.log("This is %cMy stylish message", "color: yellow; font-style: italic; background-color: blue;padding: 2px");+console.log("This is %cMy stylish message", "color: yellow; font-style: italic; background-color: blue;padding: 2px");The text before the directive will not be affected, but the text after the directive will be styled using the CSS declarations in the parameter.
@@ -187,7 +187,7 @@Using groups in the console
To exit the current group, call
-console.groupEnd()
. For example, given this code:console.log("This is the outer level"); +console.log("This is the outer level"); console.group("First group"); console.log("In the first group"); console.group("Second group"); @@ -209,7 +209,7 @@Timers
For example, given this code:
-console.time("answer time"); +console.time("answer time"); alert("Click to continue"); console.timeLog("answer time"); alert("Do a bunch of other stuff..."); @@ -228,7 +228,7 @@Stack traces
The console object also supports outputting a stack trace; this will show you the call path taken to reach the point at which you call {{domxref("console.trace()")}}. Given code like this:
-function foo() { +function foo() { function bar() { console.trace(); } diff --git a/files/en-us/web/api/console/info/index.html b/files/en-us/web/api/console/info/index.html index 7c36d3bbf6026a2..cd173ae262db286 100644 --- a/files/en-us/web/api/console/info/index.html +++ b/files/en-us/web/api/console/info/index.html @@ -18,7 +18,7 @@Syntax
-console.info(obj1 [, obj2, ..., objN]); +console.info(obj1 [, obj2, ..., objN]); console.info(msg [, subst1, ..., substN]);diff --git a/files/en-us/web/api/console/log/index.html b/files/en-us/web/api/console/log/index.html index a09e8979b7eed55..d3936f23cdbda64 100644 --- a/files/en-us/web/api/console/log/index.html +++ b/files/en-us/web/api/console/log/index.html @@ -26,7 +26,7 @@Syntax
-console.log(obj1 [, obj2, ..., objN]); +console.log(obj1 [, obj2, ..., objN]); console.log(msg [, subst1, ..., substN]);diff --git a/files/en-us/web/api/console/profile/index.html b/files/en-us/web/api/console/profile/index.html index fd0fd399ce2648d..cde670956fa5460 100644 --- a/files/en-us/web/api/console/profile/index.html +++ b/files/en-us/web/api/console/profile/index.html @@ -27,7 +27,7 @@Syntax
-console.profile(profileName); +console.profile(profileName);Parameters
diff --git a/files/en-us/web/api/console/profileend/index.html b/files/en-us/web/api/console/profileend/index.html index 2dd14260ce9c2bf..cd2ffa0c21a42a1 100644 --- a/files/en-us/web/api/console/profileend/index.html +++ b/files/en-us/web/api/console/profileend/index.html @@ -39,7 +39,7 @@Syntax
-console.profileEnd(profileName); +console.profileEnd(profileName);Parameters
diff --git a/files/en-us/web/api/console/table/index.html b/files/en-us/web/api/console/table/index.html index 09a4f8bd02f7470..1dd199353edddd4 100644 --- a/files/en-us/web/api/console/table/index.html +++ b/files/en-us/web/api/console/table/index.html @@ -126,7 +126,7 @@Sorting columns
Syntax
-console.table(data [, columns]); +console.table(data [, columns]);Parameters
diff --git a/files/en-us/web/api/console/time/index.html b/files/en-us/web/api/console/time/index.html index 24f794a9c6c216c..c39907c23f62a3e 100644 --- a/files/en-us/web/api/console/time/index.html +++ b/files/en-us/web/api/console/time/index.html @@ -24,7 +24,7 @@Syntax
-console.time(label); +console.time(label);Parameters
diff --git a/files/en-us/web/api/console/timeend/index.html b/files/en-us/web/api/console/timeend/index.html index 878e4cda11e070c..54ff83211d83d59 100644 --- a/files/en-us/web/api/console/timeend/index.html +++ b/files/en-us/web/api/console/timeend/index.html @@ -21,7 +21,7 @@Syntax
-console.timeEnd(label); +console.timeEnd(label);Parameters
diff --git a/files/en-us/web/api/console/timelog/index.html b/files/en-us/web/api/console/timelog/index.html index 71327c8ac56e476..b4698cca9bf77ec 100644 --- a/files/en-us/web/api/console/timelog/index.html +++ b/files/en-us/web/api/console/timelog/index.html @@ -22,7 +22,7 @@Syntax
-console.timeLog(label);+console.timeLog(label);Parameters
diff --git a/files/en-us/web/api/console/timestamp/index.html b/files/en-us/web/api/console/timestamp/index.html index d1310be2b1009ff..bad6231c9b2c0a3 100644 --- a/files/en-us/web/api/console/timestamp/index.html +++ b/files/en-us/web/api/console/timestamp/index.html @@ -25,7 +25,7 @@Syntax
-console.timeStamp(label); +console.timeStamp(label);Parameters
diff --git a/files/en-us/web/api/console/trace/index.html b/files/en-us/web/api/console/trace/index.html index 49be0e8ad15078a..bd9abb732608247 100644 --- a/files/en-us/web/api/console/trace/index.html +++ b/files/en-us/web/api/console/trace/index.html @@ -28,7 +28,7 @@Syntax
-console.trace( [...any, ...data ]); +console.trace( [...any, ...data ]);Parameters
diff --git a/files/en-us/web/api/console/warn/index.html b/files/en-us/web/api/console/warn/index.html index 7fe9d855165ca1a..e1d5bc08b9428b2 100644 --- a/files/en-us/web/api/console/warn/index.html +++ b/files/en-us/web/api/console/warn/index.html @@ -18,7 +18,7 @@Syntax
-console.warn(obj1 [, obj2, ..., objN]); +console.warn(obj1 [, obj2, ..., objN]); console.warn(msg [, subst1, ..., substN]);diff --git a/files/en-us/web/api/countqueuingstrategy/countqueuingstrategy/index.html b/files/en-us/web/api/countqueuingstrategy/countqueuingstrategy/index.html index ce2948a0dda5b49..3a9f6aa82c29582 100644 --- a/files/en-us/web/api/countqueuingstrategy/countqueuingstrategy/index.html +++ b/files/en-us/web/api/countqueuingstrategy/countqueuingstrategy/index.html @@ -17,7 +17,7 @@Syntax
var countQueuingStrategy = new CountQueuingStrategy({highWaterMark});+ class="brush: js">var countQueuingStrategy = new CountQueuingStrategy({highWaterMark});Parameters
diff --git a/files/en-us/web/api/countqueuingstrategy/size/index.html b/files/en-us/web/api/countqueuingstrategy/size/index.html index d1d67e1fcd1dc4d..a2f3d8ffc610f1d 100644 --- a/files/en-us/web/api/countqueuingstrategy/size/index.html +++ b/files/en-us/web/api/countqueuingstrategy/size/index.html @@ -19,7 +19,7 @@Syntax
+ class="brush: js">var size =
countQueuingStrategy.size();var size =
countQueuingStrategy.size();Parameters
diff --git a/files/en-us/web/api/cssmathmax/cssmathmax/index.html b/files/en-us/web/api/cssmathmax/cssmathmax/index.html index 80edd0684a30ee5..60f31b313f89d04 100644 --- a/files/en-us/web/api/cssmathmax/cssmathmax/index.html +++ b/files/en-us/web/api/cssmathmax/cssmathmax/index.html @@ -19,7 +19,7 @@Syntax
var CSSMathMax = new CSSMathMax(args);+ class="brush: js">var CSSMathMax = new CSSMathMax(args);Parameters
diff --git a/files/en-us/web/api/cssmathmax/values/index.html b/files/en-us/web/api/cssmathmax/values/index.html index af831a68005289e..73662055c6c23a7 100644 --- a/files/en-us/web/api/cssmathmax/values/index.html +++ b/files/en-us/web/api/cssmathmax/values/index.html @@ -19,7 +19,7 @@Syntax
var cssNumericArray = CSSMathMax.values;+ class="brush: js">var cssNumericArray = CSSMathMax.values;Value
diff --git a/files/en-us/web/api/cssmathvalue/operator/index.html b/files/en-us/web/api/cssmathvalue/operator/index.html index 21b5cf367583485..47d4d86d8a29ea2 100644 --- a/files/en-us/web/api/cssmathvalue/operator/index.html +++ b/files/en-us/web/api/cssmathvalue/operator/index.html @@ -21,7 +21,7 @@Syntax
-var aString = CSSMathValue.operator;+var aString = CSSMathValue.operator;Value
@@ -73,18 +73,18 @@Examples
thenconsole.log()
theoperator
. -<div>My width has a <code>calc()</code> function</div> +<div>My width has a <code>calc()</code> function</div>We assign a
-width
with a calculationdiv { +div { width: calc(50% - 0.5vw); }We add the JavaScript
-const styleMap = document.querySelector('div').computedStyleMap(); +const styleMap = document.querySelector('div').computedStyleMap(); console.log( styleMap.get('width') ); // CSSMathSum {values: CSSNumericArray, operator: "sum"} console.log( styleMap.get('width').values ); // CSSNumericArray {0: CSSUnitValue, 1: CSSMathNegate, length: 2} diff --git a/files/en-us/web/api/cssprimitivevalue/getrgbcolorvalue/index.html b/files/en-us/web/api/cssprimitivevalue/getrgbcolorvalue/index.html index ed4bfab9fc06611..b3bd327102b9587 100644 --- a/files/en-us/web/api/cssprimitivevalue/getrgbcolorvalue/index.html +++ b/files/en-us/web/api/cssprimitivevalue/getrgbcolorvalue/index.html @@ -18,7 +18,7 @@Syntax
var rgbColorValue = cssPrimitiveValue.getRGBColorValue();+ class="brush: js">var rgbColorValue = cssPrimitiveValue.getRGBColorValue();Return value
diff --git a/files/en-us/web/api/cssprimitivevalue/setfloatvalue/index.html b/files/en-us/web/api/cssprimitivevalue/setfloatvalue/index.html index 5be0bbd4c09eb23..b8184ce14197716 100644 --- a/files/en-us/web/api/cssprimitivevalue/setfloatvalue/index.html +++ b/files/en-us/web/api/cssprimitivevalue/setfloatvalue/index.html @@ -18,7 +18,7 @@Syntax
cssPrimitiveValue.setFloatValue(unitType, floatValue);+ class="brush: js">cssPrimitiveValue.setFloatValue(unitType, floatValue);Parameters
diff --git a/files/en-us/web/api/cssprimitivevalue/setstringvalue/index.html b/files/en-us/web/api/cssprimitivevalue/setstringvalue/index.html index 4311257b4a9717d..dc5c2754932a290 100644 --- a/files/en-us/web/api/cssprimitivevalue/setstringvalue/index.html +++ b/files/en-us/web/api/cssprimitivevalue/setstringvalue/index.html @@ -18,7 +18,7 @@Syntax
cssPrimitiveValue.setStringValue(stringType, stringValue);+ class="brush: js">cssPrimitiveValue.setStringValue(stringType, stringValue);Parameters
diff --git a/files/en-us/web/api/csspseudoelement/element/index.html b/files/en-us/web/api/csspseudoelement/element/index.html index 45fab0aa5b8d278..fbe2c82a73d2ea8 100644 --- a/files/en-us/web/api/csspseudoelement/element/index.html +++ b/files/en-us/web/api/csspseudoelement/element/index.html @@ -17,7 +17,7 @@Syntax
-var originatingElement = cssPseudoElement.element; +var originatingElement = cssPseudoElement.element;Value
diff --git a/files/en-us/web/api/csspseudoelement/type/index.html b/files/en-us/web/api/csspseudoelement/type/index.html index ad4c039d6cfc45b..a969806e3563f0a 100644 --- a/files/en-us/web/api/csspseudoelement/type/index.html +++ b/files/en-us/web/api/csspseudoelement/type/index.html @@ -18,7 +18,7 @@Syntax
-var typeOfPseudoElement = cssPseudoElement.type; +var typeOfPseudoElement = cssPseudoElement.type;Value
diff --git a/files/en-us/web/api/deviceorientationevent/absolute/index.html b/files/en-us/web/api/deviceorientationevent/absolute/index.html index cae22d2e80f33bc..7f4405002a85f72 100644 --- a/files/en-us/web/api/deviceorientationevent/absolute/index.html +++ b/files/en-us/web/api/deviceorientationevent/absolute/index.html @@ -20,7 +20,7 @@Syntax
-var absolute = instanceOfDeviceOrientationEvent.absolute; +var absolute = instanceOfDeviceOrientationEvent.absolute;On return,
absolute
istrue
if the orientation data diff --git a/files/en-us/web/api/deviceorientationevent/alpha/index.html b/files/en-us/web/api/deviceorientationevent/alpha/index.html index c7bb484a4098fad..ec18aa7a1c4d46c 100644 --- a/files/en-us/web/api/deviceorientationevent/alpha/index.html +++ b/files/en-us/web/api/deviceorientationevent/alpha/index.html @@ -20,7 +20,7 @@Syntax
-var alpha = instanceOfDeviceOrientationEvent.alpha; +var alpha = instanceOfDeviceOrientationEvent.alpha;Specifications
diff --git a/files/en-us/web/api/deviceorientationevent/beta/index.html b/files/en-us/web/api/deviceorientationevent/beta/index.html index c5ca984d633b85f..6937fa20200ff88 100644 --- a/files/en-us/web/api/deviceorientationevent/beta/index.html +++ b/files/en-us/web/api/deviceorientationevent/beta/index.html @@ -22,7 +22,7 @@Syntax
var beta = instanceOfDeviceOrientationEvent.beta;+ class="brush: js">var beta = instanceOfDeviceOrientationEvent.beta;Specifications
diff --git a/files/en-us/web/api/deviceorientationevent/deviceorientationevent/index.html b/files/en-us/web/api/deviceorientationevent/deviceorientationevent/index.html index 0d0e425951e65c2..baae88ff3e1111d 100644 --- a/files/en-us/web/api/deviceorientationevent/deviceorientationevent/index.html +++ b/files/en-us/web/api/deviceorientationevent/deviceorientationevent/index.html @@ -17,7 +17,7 @@Syntax
var deviceOrientationEvent = new DeviceOrientationEvent(type[, options])+ class="brush: js">var deviceOrientationEvent = new DeviceOrientationEvent(type[, options])Parameters
diff --git a/files/en-us/web/api/deviceorientationevent/gamma/index.html b/files/en-us/web/api/deviceorientationevent/gamma/index.html index 394dabac802df01..83832dbcdc70006 100644 --- a/files/en-us/web/api/deviceorientationevent/gamma/index.html +++ b/files/en-us/web/api/deviceorientationevent/gamma/index.html @@ -21,7 +21,7 @@Syntax
-var gamma = orientationEvent.gamma; +var gamma = orientationEvent.gamma;Specifications
diff --git a/files/en-us/web/api/deviceorientationevent/index.html b/files/en-us/web/api/deviceorientationevent/index.html index 483eeb0498a336c..483830371797f9c 100644 --- a/files/en-us/web/api/deviceorientationevent/index.html +++ b/files/en-us/web/api/deviceorientationevent/index.html @@ -38,7 +38,7 @@Properties
Example
-window.addEventListener('deviceorientation', function(event) { +window.addEventListener('deviceorientation', function(event) { console.log(event.alpha + ' : ' + event.beta + ' : ' + event.gamma); });diff --git a/files/en-us/web/api/eventlistener/handleevent/index.html b/files/en-us/web/api/eventlistener/handleevent/index.html index 37d0691bec00bbb..77a23025246dec4 100644 --- a/files/en-us/web/api/eventlistener/handleevent/index.html +++ b/files/en-us/web/api/eventlistener/handleevent/index.html @@ -26,7 +26,7 @@Syntax
-eventListener.handleEvent(event);
+eventListener.handleEvent(event);
Parameters
diff --git a/files/en-us/web/api/filereader/abort/index.html b/files/en-us/web/api/filereader/abort/index.html index 44b0c80925925fe..90d0105bf0a6572 100644 --- a/files/en-us/web/api/filereader/abort/index.html +++ b/files/en-us/web/api/filereader/abort/index.html @@ -17,7 +17,7 @@Syntax
-instanceOfFileReader.abort();+instanceOfFileReader.abort();Exceptions
diff --git a/files/en-us/web/api/filereader/error/index.html b/files/en-us/web/api/filereader/error/index.html index a186a0b5441ad81..e87dd097dda48cd 100644 --- a/files/en-us/web/api/filereader/error/index.html +++ b/files/en-us/web/api/filereader/error/index.html @@ -15,7 +15,7 @@Syntax
-var error = instanceOfFileReader.error +var error = instanceOfFileReader.errorValue
diff --git a/files/en-us/web/api/filereader/onabort/index.html b/files/en-us/web/api/filereader/onabort/index.html index e10bc3aa6c58729..f74108ad12aa236 100644 --- a/files/en-us/web/api/filereader/onabort/index.html +++ b/files/en-us/web/api/filereader/onabort/index.html @@ -12,7 +12,7 @@Syntax
-reader.onabort = function() { ... };+reader.onabort = function() { ... };Browser compatibility
diff --git a/files/en-us/web/api/filereader/onerror/index.html b/files/en-us/web/api/filereader/onerror/index.html index 6c033c157a99c4e..5e954be1298234d 100644 --- a/files/en-us/web/api/filereader/onerror/index.html +++ b/files/en-us/web/api/filereader/onerror/index.html @@ -4,7 +4,7 @@ ---The FileReader onerror handler receives an Event object, not an Error object, as a parameter, but an error can be accessed from the FileReader object, as
-instanceOfFileReader.error
// Callback from a <input type="file" onchange="onChange(event)"> +// Callback from a <input type="file" onchange="onChange(event)"> function onChange(event) { var file = event.target.files[0]; var reader = new FileReader(); diff --git a/files/en-us/web/api/filereader/readasarraybuffer/index.html b/files/en-us/web/api/filereader/readasarraybuffer/index.html index 4fc2d69d9e25bab..b4c35d2a572711c 100644 --- a/files/en-us/web/api/filereader/readasarraybuffer/index.html +++ b/files/en-us/web/api/filereader/readasarraybuffer/index.html @@ -30,7 +30,7 @@Syntax
instanceOfFileReader.readAsArrayBuffer(blob);+ class="brush: js">instanceOfFileReader.readAsArrayBuffer(blob);Parameters
diff --git a/files/en-us/web/api/filereader/readasbinarystring/index.html b/files/en-us/web/api/filereader/readasbinarystring/index.html index fb9c6fc7cc2fedd..3c6fc676564beba 100644 --- a/files/en-us/web/api/filereader/readasbinarystring/index.html +++ b/files/en-us/web/api/filereader/readasbinarystring/index.html @@ -24,7 +24,7 @@Syntax
instanceOfFileReader.readAsBinaryString(blob);+ class="brush: js">instanceOfFileReader.readAsBinaryString(blob);Parameters
diff --git a/files/en-us/web/api/filereader/readasdataurl/index.html b/files/en-us/web/api/filereader/readasdataurl/index.html index 14fa6eba5bdaad2..61f22f44fd21a09 100644 --- a/files/en-us/web/api/filereader/readasdataurl/index.html +++ b/files/en-us/web/api/filereader/readasdataurl/index.html @@ -28,7 +28,7 @@Syntax
instanceOfFileReader.readAsDataURL(blob);+ class="brush: js">instanceOfFileReader.readAsDataURL(blob);Parameters
diff --git a/files/en-us/web/api/filereader/readastext/index.html b/files/en-us/web/api/filereader/readastext/index.html index a24a627dc08a2f8..e172ab8a420acab 100644 --- a/files/en-us/web/api/filereader/readastext/index.html +++ b/files/en-us/web/api/filereader/readastext/index.html @@ -26,7 +26,7 @@Syntax
instanceOfFileReader.readAsText(blob[, encoding]);+ class="brush: js">instanceOfFileReader.readAsText(blob[, encoding]);Parameters
diff --git a/files/en-us/web/api/filereader/result/index.html b/files/en-us/web/api/filereader/result/index.html index 13b5faaa2d5afef..ec89765ce60bd1b 100644 --- a/files/en-us/web/api/filereader/result/index.html +++ b/files/en-us/web/api/filereader/result/index.html @@ -19,7 +19,7 @@Syntax
-var file = instanceOfFileReader.result +var file = instanceOfFileReader.resultValue
diff --git a/files/en-us/web/api/filesystemdirectoryhandle/entries/index.html b/files/en-us/web/api/filesystemdirectoryhandle/entries/index.html index 0e626a27948ef4b..d476821c48bbee5 100644 --- a/files/en-us/web/api/filesystemdirectoryhandle/entries/index.html +++ b/files/en-us/web/api/filesystemdirectoryhandle/entries/index.html @@ -20,7 +20,7 @@Syntax
-FileSystemDirectoryHandle.entries();+FileSystemDirectoryHandle.entries();Parameters
diff --git a/files/en-us/web/api/filesystemdirectoryhandle/getdirectoryhandle/index.html b/files/en-us/web/api/filesystemdirectoryhandle/getdirectoryhandle/index.html index 5399423ad2725eb..820f2462dfb9ee7 100644 --- a/files/en-us/web/api/filesystemdirectoryhandle/getdirectoryhandle/index.html +++ b/files/en-us/web/api/filesystemdirectoryhandle/getdirectoryhandle/index.html @@ -20,7 +20,7 @@Syntax
var FileSystemDirectoryHandle = FileSystemDirectoryHandle.getDirectoryHandle();+ class="brush: js">var FileSystemDirectoryHandle = FileSystemDirectoryHandle.getDirectoryHandle();Parameters
@@ -61,7 +61,7 @@Examples
The following example returns a directory handle with the specified name, if the directory does not exist it is created.
-const dirName = 'directoryToGetName'; +const dirName = 'directoryToGetName'; // assuming we have a directory handle: 'currentDirHandle' const subDir = currentDirHandle.getDirectoryHandle(dirName, {create: true});diff --git a/files/en-us/web/api/filesystemdirectoryhandle/getfilehandle/index.html b/files/en-us/web/api/filesystemdirectoryhandle/getfilehandle/index.html index 07e6be1332d07ed..acd86122dcafdb7 100644 --- a/files/en-us/web/api/filesystemdirectoryhandle/getfilehandle/index.html +++ b/files/en-us/web/api/filesystemdirectoryhandle/getfilehandle/index.html @@ -19,7 +19,7 @@Syntax
var FileSystemFileHandle = FileSystemDirectoryHandle.getFileHandle(name);+ class="brush: js">var FileSystemFileHandle = FileSystemDirectoryHandle.getFileHandle(name);Parameters
@@ -61,7 +61,7 @@Examples
The following example returns a file handle with the specified name, if the file does not exist it is created.
-const fileName = 'fileToGetName'; +const fileName = 'fileToGetName'; // assuming we have a directory handle: 'currentDirHandle' const fileHandle = currentDirHandle.getFileHandle(fileName, {create: true});diff --git a/files/en-us/web/api/filesystemdirectoryhandle/index.html b/files/en-us/web/api/filesystemdirectoryhandle/index.html index 33ba95e0dbdd230..1ff08565f718f1d 100644 --- a/files/en-us/web/api/filesystemdirectoryhandle/index.html +++ b/files/en-us/web/api/filesystemdirectoryhandle/index.html @@ -43,14 +43,14 @@Examples
The following example returns a directory handle with the specified name, if the directory does not exist it is created.
-const dirName = 'directoryToGetName'; +const dirName = 'directoryToGetName'; // assuming we have a directory handle: 'currentDirHandle' const subDir = currentDirHandle.getDirectoryHandle(dirName, {create: true});The following asynchronous function uses
-resolve()
to find the path to a chosen file, relative to a specified directory handle.async function returnPathDirectories(directoryHandle) { +async function returnPathDirectories(directoryHandle) { // Get a file handle by showing a file picker: const handle = await self.showOpenFilePicker(); diff --git a/files/en-us/web/api/filesystemdirectoryhandle/keys/index.html b/files/en-us/web/api/filesystemdirectoryhandle/keys/index.html index 176463a51f9b017..7988f2b87bc95e1 100644 --- a/files/en-us/web/api/filesystemdirectoryhandle/keys/index.html +++ b/files/en-us/web/api/filesystemdirectoryhandle/keys/index.html @@ -18,7 +18,7 @@Syntax
-FileSystemDirectoryHandle.keys();+FileSystemDirectoryHandle.keys();Parameters
diff --git a/files/en-us/web/api/filesystemdirectoryhandle/removeentry/index.html b/files/en-us/web/api/filesystemdirectoryhandle/removeentry/index.html index fdb8c45100e02ca..fd910e60e4b69ac 100644 --- a/files/en-us/web/api/filesystemdirectoryhandle/removeentry/index.html +++ b/files/en-us/web/api/filesystemdirectoryhandle/removeentry/index.html @@ -18,7 +18,7 @@Syntax
FileSystemDirectoryHandle.removeEntry(name).then...+ class="brush: js">FileSystemDirectoryHandle.removeEntry(name).then...Parameters
@@ -58,7 +58,7 @@Examples
The following example removes an entry within the directory handle.
-const entryName = 'entryToRemove'; +const entryName = 'entryToRemove'; // assuming we have a directory handle: 'currentDirHandle' currentDirHandle.removeEntry(entryName).then( () => { diff --git a/files/en-us/web/api/filesystemdirectoryhandle/resolve/index.html b/files/en-us/web/api/filesystemdirectoryhandle/resolve/index.html index e93e6010907d817..48e0e573f6b1a76 100644 --- a/files/en-us/web/api/filesystemdirectoryhandle/resolve/index.html +++ b/files/en-us/web/api/filesystemdirectoryhandle/resolve/index.html @@ -19,7 +19,7 @@Syntax
var pathArr = FileSystemDirectoryHandle.resolve(possibleDescendant);+ class="brush: js">var pathArr = FileSystemDirectoryHandle.resolve(possibleDescendant);Parameters
@@ -43,7 +43,7 @@Examples
The following asynchronous function uses
-resolve()
to find the path to a chosen file, relative to a specified directory handle.async function returnPathDirectories(directoryHandle) { +async function returnPathDirectories(directoryHandle) { // Get a file handle by showing a file picker: const handle = await self.showOpenFilePicker(); diff --git a/files/en-us/web/api/filesystemdirectoryhandle/values/index.html b/files/en-us/web/api/filesystemdirectoryhandle/values/index.html index 8db053d03e27f83..4fb1dba74390bce 100644 --- a/files/en-us/web/api/filesystemdirectoryhandle/values/index.html +++ b/files/en-us/web/api/filesystemdirectoryhandle/values/index.html @@ -19,7 +19,7 @@Syntax
-FileSystemDirectoryHandle.values();+FileSystemDirectoryHandle.values();Parameters
diff --git a/files/en-us/web/api/htmliframeelement/allowpaymentrequest/index.html b/files/en-us/web/api/htmliframeelement/allowpaymentrequest/index.html index b43f302e3d4c047..9270bde627b1f89 100644 --- a/files/en-us/web/api/htmliframeelement/allowpaymentrequest/index.html +++ b/files/en-us/web/api/htmliframeelement/allowpaymentrequest/index.html @@ -20,7 +20,7 @@Syntax
-var allow = htmlIFrameElement.allowPaymentRequest+var allow = htmlIFrameElement.allowPaymentRequestValue
diff --git a/files/en-us/web/api/htmliframeelement/csp/index.html b/files/en-us/web/api/htmliframeelement/csp/index.html index 64b9f8e9a0ced1d..333de00d7fcaed1 100644 --- a/files/en-us/web/api/htmliframeelement/csp/index.html +++ b/files/en-us/web/api/htmliframeelement/csp/index.html @@ -18,7 +18,7 @@Syntax
-var csp = HTMLIFrameElement.csp +var csp = HTMLIFrameElement.csp HTMLIFrameElement.csp = cspValue
diff --git a/files/en-us/web/api/htmliframeelement/featurepolicy/index.html b/files/en-us/web/api/htmliframeelement/featurepolicy/index.html index f7dd2aeae2f3c13..484a4753b5b5175 100644 --- a/files/en-us/web/api/htmliframeelement/featurepolicy/index.html +++ b/files/en-us/web/api/htmliframeelement/featurepolicy/index.html @@ -19,7 +19,7 @@Syntax
var policy = HTMLIFrameElement.featurePolicy+ class="brush: js">var policy = HTMLIFrameElement.featurePolicyValue
diff --git a/files/en-us/web/api/htmliframeelement/referrerpolicy/index.html b/files/en-us/web/api/htmliframeelement/referrerpolicy/index.html index 1e942a9617ad679..8978e42433b6760 100644 --- a/files/en-us/web/api/htmliframeelement/referrerpolicy/index.html +++ b/files/en-us/web/api/htmliframeelement/referrerpolicy/index.html @@ -18,7 +18,7 @@Syntax
-refStr = iframeElt.referrerPolicy; +refStr = iframeElt.referrerPolicy; iframeElt.referrerPolicy = refStr;Values
diff --git a/files/en-us/web/api/htmliframeelement/src/index.html b/files/en-us/web/api/htmliframeelement/src/index.html index 3d898601bd0ccfb..cefe5f09d60de05 100644 --- a/files/en-us/web/api/htmliframeelement/src/index.html +++ b/files/en-us/web/api/htmliframeelement/src/index.html @@ -11,7 +11,7 @@Syntax
-refStr = iframeElt.src; +refStr = iframeElt.src; iframeElt.src= refStr;diff --git a/files/en-us/web/api/htmllinkelement/as/index.html b/files/en-us/web/api/htmllinkelement/as/index.html index d8012942539a41f..39db10dd09caf85 100644 --- a/files/en-us/web/api/htmllinkelement/as/index.html +++ b/files/en-us/web/api/htmllinkelement/as/index.html @@ -21,7 +21,7 @@Syntax
-var as = HTMLLinkElement.as +var as = HTMLLinkElement.as HTMLLinkElement.as = asValue
diff --git a/files/en-us/web/api/htmllinkelement/referrerpolicy/index.html b/files/en-us/web/api/htmllinkelement/referrerpolicy/index.html index 036a25d651066a3..5bc84652bc7791d 100644 --- a/files/en-us/web/api/htmllinkelement/referrerpolicy/index.html +++ b/files/en-us/web/api/htmllinkelement/referrerpolicy/index.html @@ -20,7 +20,7 @@Syntax
-DOMString HTMLLinkElement.referrerPolicy+DOMString HTMLLinkElement.referrerPolicyExample
diff --git a/files/en-us/web/api/htmllinkelement/rel/index.html b/files/en-us/web/api/htmllinkelement/rel/index.html index 006f43ab923e479..70f83363f824d86 100644 --- a/files/en-us/web/api/htmllinkelement/rel/index.html +++ b/files/en-us/web/api/htmllinkelement/rel/index.html @@ -22,7 +22,7 @@Syntax
-var relstr = linkElt.rel; +var relstr = linkElt.rel; linkElt.rel = relstr;diff --git a/files/en-us/web/api/htmllinkelement/rellist/index.html b/files/en-us/web/api/htmllinkelement/rellist/index.html index 1abf9c9dbd62eec..4459e8fa5069de7 100644 --- a/files/en-us/web/api/htmllinkelement/rellist/index.html +++ b/files/en-us/web/api/htmllinkelement/rellist/index.html @@ -23,7 +23,7 @@Syntax
-var relstr = linkElt.relList; +var relstr = linkElt.relList;Example
diff --git a/files/en-us/web/api/htmlshadowelement/getdistributednodes/index.html b/files/en-us/web/api/htmlshadowelement/getdistributednodes/index.html index 996f870aaab7c26..bdb0a78736d269b 100644 --- a/files/en-us/web/api/htmlshadowelement/getdistributednodes/index.html +++ b/files/en-us/web/api/htmlshadowelement/getdistributednodes/index.html @@ -16,7 +16,7 @@Syntax
-var nodeList = object.getDistributedNodes() +var nodeList = object.getDistributedNodes()Example
diff --git a/files/en-us/web/api/htmltableelement/align/index.html b/files/en-us/web/api/htmltableelement/align/index.html index 4576c88c8becc2e..c38060f796ae1c4 100644 --- a/files/en-us/web/api/htmltableelement/align/index.html +++ b/files/en-us/web/api/htmltableelement/align/index.html @@ -18,7 +18,7 @@Syntax
-HTMLTableElement.align = alignment; +HTMLTableElement.align = alignment; var alignment = HTMLTableElement.align;Parameters
diff --git a/files/en-us/web/api/htmltableelement/bgcolor/index.html b/files/en-us/web/api/htmltableelement/bgcolor/index.html index 105be617e587090..25d4cf94f0310a4 100644 --- a/files/en-us/web/api/htmltableelement/bgcolor/index.html +++ b/files/en-us/web/api/htmltableelement/bgcolor/index.html @@ -27,7 +27,7 @@Syntax
-color = table.bgColor +color = table.bgColor table.bgColor = colorParameters
diff --git a/files/en-us/web/api/htmltableelement/border/index.html b/files/en-us/web/api/htmltableelement/border/index.html index 2f5a74621b75a63..6af085793520220 100644 --- a/files/en-us/web/api/htmltableelement/border/index.html +++ b/files/en-us/web/api/htmltableelement/border/index.html @@ -16,7 +16,7 @@Syntax
-HTMLTableElement.border = border; +HTMLTableElement.border = border; var border = HTMLTableElement.border;diff --git a/files/en-us/web/api/htmltableelement/caption/index.html b/files/en-us/web/api/htmltableelement/caption/index.html index db7cce01149c447..fbed8e431b78922 100644 --- a/files/en-us/web/api/htmltableelement/caption/index.html +++ b/files/en-us/web/api/htmltableelement/caption/index.html @@ -16,7 +16,7 @@Syntax
var string = tableElement.caption;+ class="brush: js">var string = tableElement.caption;Example
diff --git a/files/en-us/web/api/htmltableelement/cellpadding/index.html b/files/en-us/web/api/htmltableelement/cellpadding/index.html index 6de4538042f2c79..0032249dc1630c2 100644 --- a/files/en-us/web/api/htmltableelement/cellpadding/index.html +++ b/files/en-us/web/api/htmltableelement/cellpadding/index.html @@ -15,7 +15,7 @@Syntax
-HTMLTableElement.cellPadding = padding; +HTMLTableElement.cellPadding = padding; var padding = HTMLTableElement.cellPadding;
HTMLTableElement.cellSpacing = spacing; +HTMLTableElement.cellSpacing = spacing; var spacing = HTMLTableElement.cellSpacing;Value
diff --git a/files/en-us/web/api/htmltableelement/createcaption/index.html b/files/en-us/web/api/htmltableelement/createcaption/index.html index cca18c8ec1fc390..551c4cd75845dd9 100644 --- a/files/en-us/web/api/htmltableelement/createcaption/index.html +++ b/files/en-us/web/api/htmltableelement/createcaption/index.html @@ -26,7 +26,7 @@Syntax
HTMLTableElement = table.createCaption();+ class="brush: js">HTMLTableElement = table.createCaption();
<table> +<table> <tr><td>Cell 1.1</td><td>Cell 1.2</td><td>Cell 1.3</td></tr> <tr><td>Cell 2.1</td><td>Cell 2.2</td><td>Cell 2.3</td></tr> </table>JavaScript
-let table = document.querySelector('table'); +let table = document.querySelector('table'); let caption = table.createCaption(); caption.textContent = 'This caption was created by JavaScript!';diff --git a/files/en-us/web/api/htmltableelement/createtbody/index.html b/files/en-us/web/api/htmltableelement/createtbody/index.html index 60633663af242cf..04908c9c24093d8 100644 --- a/files/en-us/web/api/htmltableelement/createtbody/index.html +++ b/files/en-us/web/api/htmltableelement/createtbody/index.html @@ -25,7 +25,7 @@Syntax
-table.createTBody();+table.createTBody();Return value
diff --git a/files/en-us/web/api/htmltableelement/createtfoot/index.html b/files/en-us/web/api/htmltableelement/createtfoot/index.html index 20bda65d320345d..01a1881f7bb3cfe 100644 --- a/files/en-us/web/api/htmltableelement/createtfoot/index.html +++ b/files/en-us/web/api/htmltableelement/createtfoot/index.html @@ -25,7 +25,7 @@Syntax
-table.createTFoot();+table.createTFoot();Return value
diff --git a/files/en-us/web/api/htmltableelement/createthead/index.html b/files/en-us/web/api/htmltableelement/createthead/index.html index 93ff26a392b9f5b..417194552df504d 100644 --- a/files/en-us/web/api/htmltableelement/createthead/index.html +++ b/files/en-us/web/api/htmltableelement/createthead/index.html @@ -25,7 +25,7 @@Syntax
-table.createTHead();+table.createTHead();Return value
diff --git a/files/en-us/web/api/htmltableelement/deletecaption/index.html b/files/en-us/web/api/htmltableelement/deletecaption/index.html index 5b01aa89d0a789d..8c47b2a3a3d7a67 100644 --- a/files/en-us/web/api/htmltableelement/deletecaption/index.html +++ b/files/en-us/web/api/htmltableelement/deletecaption/index.html @@ -18,7 +18,7 @@Syntax
-HTMLTableElement.deleteCaption()+HTMLTableElement.deleteCaption()Example
diff --git a/files/en-us/web/api/htmltableelement/deleterow/index.html b/files/en-us/web/api/htmltableelement/deleterow/index.html index bee13058c34e006..e1c5d3ad23ad644 100644 --- a/files/en-us/web/api/htmltableelement/deleterow/index.html +++ b/files/en-us/web/api/htmltableelement/deleterow/index.html @@ -17,7 +17,7 @@Syntax
HTMLTableElement.deleteRow(index)+ class="brush: js">HTMLTableElement.deleteRow(index)Parameters
diff --git a/files/en-us/web/api/htmltableelement/deletetfoot/index.html b/files/en-us/web/api/htmltableelement/deletetfoot/index.html index 20c30f01455edde..166259d38c44fd9 100644 --- a/files/en-us/web/api/htmltableelement/deletetfoot/index.html +++ b/files/en-us/web/api/htmltableelement/deletetfoot/index.html @@ -16,7 +16,7 @@Syntax
-HTMLTableElement.deleteTFoot();+HTMLTableElement.deleteTFoot();Example
diff --git a/files/en-us/web/api/htmltableelement/deletethead/index.html b/files/en-us/web/api/htmltableelement/deletethead/index.html index 5ce7beb15d77c49..04e4513f54ee260 100644 --- a/files/en-us/web/api/htmltableelement/deletethead/index.html +++ b/files/en-us/web/api/htmltableelement/deletethead/index.html @@ -16,7 +16,7 @@Syntax
-HTMLTableElement.deleteTHead();+HTMLTableElement.deleteTHead();Example
diff --git a/files/en-us/web/api/htmltableelement/frame/index.html b/files/en-us/web/api/htmltableelement/frame/index.html index 731cc0c527346c9..9c4d960e2ffe31f 100644 --- a/files/en-us/web/api/htmltableelement/frame/index.html +++ b/files/en-us/web/api/htmltableelement/frame/index.html @@ -19,7 +19,7 @@Syntax
-HTMLTableElement.frame = frameSides; +HTMLTableElement.frame = frameSides; var frameSides = HTMLTableElement.frame;Parameters
diff --git a/files/en-us/web/api/htmltableelement/insertrow/index.html b/files/en-us/web/api/htmltableelement/insertrow/index.html index fcd9e99b77ccb9d..08c20b757e2afe3 100644 --- a/files/en-us/web/api/htmltableelement/insertrow/index.html +++ b/files/en-us/web/api/htmltableelement/insertrow/index.html @@ -33,7 +33,7 @@Syntax
var newRow = HTMLTableElement.insertRow(index);+ class="brush: js">var newRow = HTMLTableElement.insertRow(index);{{domxref("HTMLTableElement")}} is a reference to an HTML {{HtmlElement("table")}} element.
diff --git a/files/en-us/web/api/htmltableelement/rows/index.html b/files/en-us/web/api/htmltableelement/rows/index.html index 171058d35f4a5ab..237f0b59c0f90c2 100644 --- a/files/en-us/web/api/htmltableelement/rows/index.html +++ b/files/en-us/web/api/htmltableelement/rows/index.html @@ -31,7 +31,7 @@Syntax
HTMLCollectionObject = table.rows;+ class="brush: js">HTMLCollectionObject = table.rows;
HTMLTableElement.rules = rules; +HTMLTableElement.rules = rules; var rules = HTMLTableElement.rules;Parameters
diff --git a/files/en-us/web/api/htmltableelement/summary/index.html b/files/en-us/web/api/htmltableelement/summary/index.html index 0f6a50331aa698e..1dfad0c24ae1d0e 100644 --- a/files/en-us/web/api/htmltableelement/summary/index.html +++ b/files/en-us/web/api/htmltableelement/summary/index.html @@ -17,7 +17,7 @@Syntax
-HTMLTableElement.summary = string; +HTMLTableElement.summary = string; varstring = HTMLTableElement.summary;Example
diff --git a/files/en-us/web/api/htmltableelement/tbodies/index.html b/files/en-us/web/api/htmltableelement/tbodies/index.html index 044c5a277b4fc2c..2ec82b527a464be 100644 --- a/files/en-us/web/api/htmltableelement/tbodies/index.html +++ b/files/en-us/web/api/htmltableelement/tbodies/index.html @@ -33,7 +33,7 @@Syntax
HTMLCollectionObject = table.tBodies+ class="brush: js">HTMLCollectionObject = table.tBodiesExample
diff --git a/files/en-us/web/api/htmltableelement/tfoot/index.html b/files/en-us/web/api/htmltableelement/tfoot/index.html index 770c3722bfb3640..ac7cf68e6011bcb 100644 --- a/files/en-us/web/api/htmltableelement/tfoot/index.html +++ b/files/en-us/web/api/htmltableelement/tfoot/index.html @@ -16,7 +16,7 @@Syntax
-HTMLTableSectionElementObject = table.tFoot +HTMLTableSectionElementObject = table.tFoot table.tFoot = HTMLTableSectionElementObjectdiff --git a/files/en-us/web/api/htmltableelement/thead/index.html b/files/en-us/web/api/htmltableelement/thead/index.html index 4521ce5a9230336..0725f4950c18ae0 100644 --- a/files/en-us/web/api/htmltableelement/thead/index.html +++ b/files/en-us/web/api/htmltableelement/thead/index.html @@ -16,7 +16,7 @@Syntax
-thead_element = table.tHead; +thead_element = table.tHead; table.tHead = thead_element;diff --git a/files/en-us/web/api/htmltableelement/width/index.html b/files/en-us/web/api/htmltableelement/width/index.html index 69b209045360f38..4dcf5aee9173154 100644 --- a/files/en-us/web/api/htmltableelement/width/index.html +++ b/files/en-us/web/api/htmltableelement/width/index.html @@ -17,7 +17,7 @@Syntax
-HTMLTableElement.width = width; +HTMLTableElement.width = width; var width = HTMLTableElement.width;Where
width
is a string representing the width in number of pixels or as a diff --git a/files/en-us/web/api/idbkeyrange/bound/index.html b/files/en-us/web/api/idbkeyrange/bound/index.html index 387973b2d286a5c..c3f490dc5744851 100644 --- a/files/en-us/web/api/idbkeyrange/bound/index.html +++ b/files/en-us/web/api/idbkeyrange/bound/index.html @@ -24,7 +24,7 @@Syntax
-var myIDBKeyRange = IDBKeyRange.bound(lower, upper); +var myIDBKeyRange = IDBKeyRange.bound(lower, upper); var myIDBKeyRange = IDBKeyRange.bound(lower, upper, lowerOpen); var myIDBKeyRange = IDBKeyRange.bound(lower, upper, lowerOpen, upperOpen);diff --git a/files/en-us/web/api/idbkeyrange/includes/index.html b/files/en-us/web/api/idbkeyrange/includes/index.html index 41a245b5d749193..7bbb0d77cb6b8b2 100644 --- a/files/en-us/web/api/idbkeyrange/includes/index.html +++ b/files/en-us/web/api/idbkeyrange/includes/index.html @@ -23,7 +23,7 @@Syntax
-var isIncluded = myKeyRange.includes(key)+var isIncluded = myKeyRange.includes(key)Parameters
diff --git a/files/en-us/web/api/idbkeyrange/lower/index.html b/files/en-us/web/api/idbkeyrange/lower/index.html index 9a182c2049bed1e..d7c6d69fd0c368e 100644 --- a/files/en-us/web/api/idbkeyrange/lower/index.html +++ b/files/en-us/web/api/idbkeyrange/lower/index.html @@ -22,7 +22,7 @@Syntax
-var lower = myKeyRange.lower+var lower = myKeyRange.lowerValue
diff --git a/files/en-us/web/api/idbkeyrange/lowerbound/index.html b/files/en-us/web/api/idbkeyrange/lowerbound/index.html index 5405a390156b7dc..3eb285482647016 100644 --- a/files/en-us/web/api/idbkeyrange/lowerbound/index.html +++ b/files/en-us/web/api/idbkeyrange/lowerbound/index.html @@ -23,7 +23,7 @@Syntax
-var myIDBKeyRange = IDBKeyRange.lowerBound(lower); +var myIDBKeyRange = IDBKeyRange.lowerBound(lower); var myIDBKeyRange = IDBKeyRange.lowerBound(lower, open);@@ -82,7 +82,7 @@Example
too.) -function displayData() { +function displayData() { var keyRangeValue = IDBKeyRange.lowerBound("F"); var transaction = db.transaction(['fThings'], 'readonly'); diff --git a/files/en-us/web/api/idbkeyrange/loweropen/index.html b/files/en-us/web/api/idbkeyrange/loweropen/index.html index df809635956198b..66b8e76e6bd7a34 100644 --- a/files/en-us/web/api/idbkeyrange/loweropen/index.html +++ b/files/en-us/web/api/idbkeyrange/loweropen/index.html @@ -23,7 +23,7 @@Syntax
-var lowerOpen = myKeyRange.lowerOpen+var lowerOpen = myKeyRange.lowerOpenValue
diff --git a/files/en-us/web/api/idbkeyrange/only/index.html b/files/en-us/web/api/idbkeyrange/only/index.html index 772b3a2d00631e4..9a97d8b14efff62 100644 --- a/files/en-us/web/api/idbkeyrange/only/index.html +++ b/files/en-us/web/api/idbkeyrange/only/index.html @@ -23,7 +23,7 @@Syntax
var myIDBKeyRange = IDBKeyRange.only(value);+ class="brush: js">var myIDBKeyRange = IDBKeyRange.only(value);Parameters
diff --git a/files/en-us/web/api/idbkeyrange/upper/index.html b/files/en-us/web/api/idbkeyrange/upper/index.html index 42faf312ca75213..6f33a19a6ce455f 100644 --- a/files/en-us/web/api/idbkeyrange/upper/index.html +++ b/files/en-us/web/api/idbkeyrange/upper/index.html @@ -22,7 +22,7 @@Syntax
-var upper = myKeyRange.upper+var upper = myKeyRange.upperValue
diff --git a/files/en-us/web/api/idbkeyrange/upperbound/index.html b/files/en-us/web/api/idbkeyrange/upperbound/index.html index 9dfd66ae8a4a272..aea4ec5ab86227a 100644 --- a/files/en-us/web/api/idbkeyrange/upperbound/index.html +++ b/files/en-us/web/api/idbkeyrange/upperbound/index.html @@ -24,7 +24,7 @@Syntax
var myIDBKeyRange = IDBKeyRange.upperBound(upper[, open=false])+ class="brush: js">var myIDBKeyRange = IDBKeyRange.upperBound(upper[, open=false])Parameters
@@ -79,7 +79,7 @@Example
too.) -function displayData() { +function displayData() { var keyRangeValue = IDBKeyRange.upperBound("F"); var transaction = db.transaction(['fThings'], 'readonly'); diff --git a/files/en-us/web/api/idbkeyrange/upperopen/index.html b/files/en-us/web/api/idbkeyrange/upperopen/index.html index 889f79c155c932f..5cce20809fe4b2d 100644 --- a/files/en-us/web/api/idbkeyrange/upperopen/index.html +++ b/files/en-us/web/api/idbkeyrange/upperopen/index.html @@ -23,7 +23,7 @@Syntax
-var upperOpen = myKeyRange.upperOpen+var upperOpen = myKeyRange.upperOpenValue
diff --git a/files/en-us/web/api/keyboard/getlayoutmap/index.html b/files/en-us/web/api/keyboard/getlayoutmap/index.html index c7c5813cef156bd..042e8193b44ce2d 100644 --- a/files/en-us/web/api/keyboard/getlayoutmap/index.html +++ b/files/en-us/web/api/keyboard/getlayoutmap/index.html @@ -22,7 +22,7 @@Syntax
var promise = Keyboard.getLayoutMap()+ class="brush: js">var promise = Keyboard.getLayoutMap()Parameters
diff --git a/files/en-us/web/api/keyboard/lock/index.html b/files/en-us/web/api/keyboard/lock/index.html index e78ca23a8c29353..dcccd4b081fa7d3 100644 --- a/files/en-us/web/api/keyboard/lock/index.html +++ b/files/en-us/web/api/keyboard/lock/index.html @@ -21,7 +21,7 @@Syntax
var promise = Keyboard.lock([keyCodes[]])+ class="brush: js">var promise = Keyboard.lock([keyCodes[]])Parameters
diff --git a/files/en-us/web/api/keyboard/unlock/index.html b/files/en-us/web/api/keyboard/unlock/index.html index e72291616d96821..5f1bead2f9bcbac 100644 --- a/files/en-us/web/api/keyboard/unlock/index.html +++ b/files/en-us/web/api/keyboard/unlock/index.html @@ -18,7 +18,7 @@Syntax
-Keyboard.unlock()+Keyboard.unlock()Parameters
diff --git a/files/en-us/web/api/mediarecorder/audiobitspersecond/index.html b/files/en-us/web/api/mediarecorder/audiobitspersecond/index.html index 6cfc4c71720a09f..8e7899a29dc8e07 100644 --- a/files/en-us/web/api/mediarecorder/audiobitspersecond/index.html +++ b/files/en-us/web/api/mediarecorder/audiobitspersecond/index.html @@ -19,7 +19,7 @@Syntax
var audioBitsPerSecond = MediaRecorder.audioBitsPerSecond+ class="brush: js">var audioBitsPerSecond = MediaRecorder.audioBitsPerSecondValue
diff --git a/files/en-us/web/api/mediarecorder/ignoremutedmedia/index.html b/files/en-us/web/api/mediarecorder/ignoremutedmedia/index.html index 781bf2078195c22..23c03406dec0a03 100644 --- a/files/en-us/web/api/mediarecorder/ignoremutedmedia/index.html +++ b/files/en-us/web/api/mediarecorder/ignoremutedmedia/index.html @@ -20,7 +20,7 @@Syntax
-var boolean = MediaRecorder.ignoreMutedMedia +var boolean = MediaRecorder.ignoreMutedMedia MediaRecorder.ignoreMutedMedia = booleanValue
diff --git a/files/en-us/web/api/mediarecorder/istypesupported/index.html b/files/en-us/web/api/mediarecorder/istypesupported/index.html index ecf83d73eb0c0ea..52753fcf346137f 100644 --- a/files/en-us/web/api/mediarecorder/istypesupported/index.html +++ b/files/en-us/web/api/mediarecorder/istypesupported/index.html @@ -23,7 +23,7 @@Syntax
var canRecord = MediaRecorder.isTypeSupported(mimeType)+ class="brush: js">var canRecord = MediaRecorder.isTypeSupported(mimeType)Parameters
diff --git a/files/en-us/web/api/mediarecorder/mediarecorder/index.html b/files/en-us/web/api/mediarecorder/mediarecorder/index.html index 88ae1524937245f..af7693f72664fac 100644 --- a/files/en-us/web/api/mediarecorder/mediarecorder/index.html +++ b/files/en-us/web/api/mediarecorder/mediarecorder/index.html @@ -25,7 +25,7 @@Syntax
var mediaRecorder = new MediaRecorder(stream[, options]);+ class="brush: js">var mediaRecorder = new MediaRecorder(stream[, options]);Parameters
diff --git a/files/en-us/web/api/mediarecorder/mimetype/index.html b/files/en-us/web/api/mediarecorder/mimetype/index.html index c3351b359a00719..4fb4d6004c60d69 100644 --- a/files/en-us/web/api/mediarecorder/mimetype/index.html +++ b/files/en-us/web/api/mediarecorder/mimetype/index.html @@ -36,7 +36,7 @@Syntax
var mimeType = mediaRecorder.mimeType+ class="brush: js">var mimeType = mediaRecorder.mimeTypeValue
diff --git a/files/en-us/web/api/mediarecorder/ondataavailable/index.html b/files/en-us/web/api/mediarecorder/ondataavailable/index.html index 9d976b002004422..166b45da6f8539b 100644 --- a/files/en-us/web/api/mediarecorder/ondataavailable/index.html +++ b/files/en-us/web/api/mediarecorder/ondataavailable/index.html @@ -54,7 +54,7 @@Syntax
-MediaRecorder.ondataavailable = function(event) { ... } +
MediaRecorder.ondataavailable = function(event) { ... } MediaRecorder.addEventListener('dataavailable', function(event) { ... })
diff --git a/files/en-us/web/api/mediarecorder/onerror/index.html b/files/en-us/web/api/mediarecorder/onerror/index.html index ef65f6a37388d9e..67eec86445e9fc4 100644 --- a/files/en-us/web/api/mediarecorder/onerror/index.html +++ b/files/en-us/web/api/mediarecorder/onerror/index.html @@ -25,7 +25,7 @@Syntax
-MediaRecorder.onerror = errorHandlerFunction; +MediaRecorder.onerror = errorHandlerFunction;Value
@@ -76,7 +76,7 @@Example
exceptions are thrown during the setup process.--function recordStream(stream) { +
function recordStream(stream) { let recorder = null; let bufferList = []; diff --git a/files/en-us/web/api/mediarecorder/onpause/index.html b/files/en-us/web/api/mediarecorder/onpause/index.html index 3aab1f6b4f20c5e..d45406214914591 100644 --- a/files/en-us/web/api/mediarecorder/onpause/index.html +++ b/files/en-us/web/api/mediarecorder/onpause/index.html @@ -24,7 +24,7 @@
Syntax
-MediaRecorder.onpause = function(event) { ... } +MediaRecorder.onpause = function(event) { ... } MediaRecorder.addEventListener('pause', function(event) { ... })diff --git a/files/en-us/web/api/mediarecorder/onresume/index.html b/files/en-us/web/api/mediarecorder/onresume/index.html index 8fc850d58826702..b18763af277dd95 100644 --- a/files/en-us/web/api/mediarecorder/onresume/index.html +++ b/files/en-us/web/api/mediarecorder/onresume/index.html @@ -24,7 +24,7 @@Syntax
-MediaRecorder.onresume = function(event) { ... } +MediaRecorder.onresume = function(event) { ... } MediaRecorder.addEventListener('resume', function(event) { ... })diff --git a/files/en-us/web/api/mediarecorder/onstart/index.html b/files/en-us/web/api/mediarecorder/onstart/index.html index 9d974bf75c7d2c9..16b8f75acb2dd2f 100644 --- a/files/en-us/web/api/mediarecorder/onstart/index.html +++ b/files/en-us/web/api/mediarecorder/onstart/index.html @@ -26,7 +26,7 @@Syntax
-MediaRecorder.onstart = function(event) { ... } +MediaRecorder.onstart = function(event) { ... } MediaRecorder.addEventListener('start', function(event) { ... })Example
diff --git a/files/en-us/web/api/mediarecorder/onstop/index.html b/files/en-us/web/api/mediarecorder/onstop/index.html index f8929879aaae34a..2ac69f4d3c2fdd7 100644 --- a/files/en-us/web/api/mediarecorder/onstop/index.html +++ b/files/en-us/web/api/mediarecorder/onstop/index.html @@ -28,7 +28,7 @@Syntax
-MediaRecorder.onstop = function(event) { ... } +MediaRecorder.onstop = function(event) { ... } MediaRecorder.addEventListener('stop', function(event) { ... })Example
diff --git a/files/en-us/web/api/mediarecorder/onwarning/index.html b/files/en-us/web/api/mediarecorder/onwarning/index.html index 3a7d74189793f52..c9df83ece80a049 100644 --- a/files/en-us/web/api/mediarecorder/onwarning/index.html +++ b/files/en-us/web/api/mediarecorder/onwarning/index.html @@ -26,7 +26,7 @@Syntax
mediaRecorder.onwarning = function(event) { ... } + class="brush: js">mediaRecorder.onwarning = function(event) { ... } mediaRecorder.addEventListener('warning', function(event) { ... })Example
diff --git a/files/en-us/web/api/mediarecorder/pause/index.html b/files/en-us/web/api/mediarecorder/pause/index.html index e24767a86f802c5..cf2189d47db40a2 100644 --- a/files/en-us/web/api/mediarecorder/pause/index.html +++ b/files/en-us/web/api/mediarecorder/pause/index.html @@ -31,7 +31,7 @@Syntax
-MediaRecorder.pause()+MediaRecorder.pause()Return value
diff --git a/files/en-us/web/api/mediarecorder/requestdata/index.html b/files/en-us/web/api/mediarecorder/requestdata/index.html index 68ff75907070452..00dcad0ba16874c 100644 --- a/files/en-us/web/api/mediarecorder/requestdata/index.html +++ b/files/en-us/web/api/mediarecorder/requestdata/index.html @@ -37,7 +37,7 @@Syntax
-MediaRecorder.requestData()+MediaRecorder.requestData()Errors
diff --git a/files/en-us/web/api/mediarecorder/resume/index.html b/files/en-us/web/api/mediarecorder/resume/index.html index 5857b26b2504b4f..4589246d848063e 100644 --- a/files/en-us/web/api/mediarecorder/resume/index.html +++ b/files/en-us/web/api/mediarecorder/resume/index.html @@ -32,7 +32,7 @@Syntax
MediaRecorder.resume()
+ class="brush: js">MediaRecorder.resume()Errors
diff --git a/files/en-us/web/api/mediarecorder/start/index.html b/files/en-us/web/api/mediarecorder/start/index.html index 233fef95312b1ba..e12d7d6e9145c67 100644 --- a/files/en-us/web/api/mediarecorder/start/index.html +++ b/files/en-us/web/api/mediarecorder/start/index.html @@ -51,7 +51,7 @@Syntax
mediaRecorder.start(timeslice)+ class="brush: js">mediaRecorder.start(timeslice)Parameters
diff --git a/files/en-us/web/api/mediarecorder/state/index.html b/files/en-us/web/api/mediarecorder/state/index.html index 1eeb462f24843a4..f4f02375153aff6 100644 --- a/files/en-us/web/api/mediarecorder/state/index.html +++ b/files/en-us/web/api/mediarecorder/state/index.html @@ -16,7 +16,7 @@Syntax
-var state = MediaRecorder.state+var state = MediaRecorder.stateValues
diff --git a/files/en-us/web/api/mediarecorder/stop/index.html b/files/en-us/web/api/mediarecorder/stop/index.html index 4daa214faeee9b2..2eb933d70fad378 100644 --- a/files/en-us/web/api/mediarecorder/stop/index.html +++ b/files/en-us/web/api/mediarecorder/stop/index.html @@ -34,7 +34,7 @@Syntax
MediaRecorder.stop()
+ class="brush: js">MediaRecorder.stop()Errors
diff --git a/files/en-us/web/api/mediarecorder/stream/index.html b/files/en-us/web/api/mediarecorder/stream/index.html index cd5c51a9793ab19..0c5415e3b09553c 100644 --- a/files/en-us/web/api/mediarecorder/stream/index.html +++ b/files/en-us/web/api/mediarecorder/stream/index.html @@ -18,7 +18,7 @@Syntax
var stream = MediaRecorder.stream+ class="brush: js">var stream = MediaRecorder.streamValues
diff --git a/files/en-us/web/api/mediarecorder/videobitspersecond/index.html b/files/en-us/web/api/mediarecorder/videobitspersecond/index.html index 60d2df972784ec7..535afaee8ea01f6 100644 --- a/files/en-us/web/api/mediarecorder/videobitspersecond/index.html +++ b/files/en-us/web/api/mediarecorder/videobitspersecond/index.html @@ -12,7 +12,7 @@Syntax
var videoBitsPerSecond = MediaRecorder.videoBitsPerSecond+ class="brush: js">var videoBitsPerSecond = MediaRecorder.videoBitsPerSecondValue
diff --git a/files/en-us/web/api/mediasettingsrange/max/index.html b/files/en-us/web/api/mediasettingsrange/max/index.html index 5cb90eb2af791c6..cddfae79a9621fe 100644 --- a/files/en-us/web/api/mediasettingsrange/max/index.html +++ b/files/en-us/web/api/mediasettingsrange/max/index.html @@ -20,7 +20,7 @@Syntax
var max = mediaSettingsRange.max+ class="brush: js">var max = mediaSettingsRange.maxValue
diff --git a/files/en-us/web/api/mediasettingsrange/min/index.html b/files/en-us/web/api/mediasettingsrange/min/index.html index 5a9643e1adf3843..eb1d9bc0f898d6d 100644 --- a/files/en-us/web/api/mediasettingsrange/min/index.html +++ b/files/en-us/web/api/mediasettingsrange/min/index.html @@ -20,7 +20,7 @@Syntax
var min = mediaSettingsRange.min+ class="brush: js">var min = mediaSettingsRange.minValue
diff --git a/files/en-us/web/api/mediasettingsrange/step/index.html b/files/en-us/web/api/mediasettingsrange/step/index.html index d2ccb318dafdcde..d67f608faa2da6c 100644 --- a/files/en-us/web/api/mediasettingsrange/step/index.html +++ b/files/en-us/web/api/mediasettingsrange/step/index.html @@ -20,7 +20,7 @@Syntax
var step = mediaSettingsRange.step+ class="brush: js">var step = mediaSettingsRange.stepValue
diff --git a/files/en-us/web/api/mouseevent/altkey/index.html b/files/en-us/web/api/mouseevent/altkey/index.html index 2076740e31b5004..0a6cd99e1e8d6d9 100644 --- a/files/en-us/web/api/mouseevent/altkey/index.html +++ b/files/en-us/web/api/mouseevent/altkey/index.html @@ -27,7 +27,7 @@Syntax
-var altKeyPressed = instanceOfMouseEvent.altKey +var altKeyPressed = instanceOfMouseEvent.altKeyReturn value
diff --git a/files/en-us/web/api/mouseevent/button/index.html b/files/en-us/web/api/mouseevent/button/index.html index e017edf38eedc03..909036d1d99ad8d 100644 --- a/files/en-us/web/api/mouseevent/button/index.html +++ b/files/en-us/web/api/mouseevent/button/index.html @@ -33,7 +33,7 @@Syntax
-var buttonPressed = instanceOfMouseEvent.button +var buttonPressed = instanceOfMouseEvent.buttonReturn value
diff --git a/files/en-us/web/api/mouseevent/buttons/index.html b/files/en-us/web/api/mouseevent/buttons/index.html index 64db2fd0f147dd9..2ce1e557e1ca702 100644 --- a/files/en-us/web/api/mouseevent/buttons/index.html +++ b/files/en-us/web/api/mouseevent/buttons/index.html @@ -33,7 +33,7 @@Syntax
-var buttonsPressed = instanceOfMouseEvent.buttons +var buttonsPressed = instanceOfMouseEvent.buttonsReturn value
@@ -59,12 +59,12 @@Example
HTML
-<p>Click anywhere with one or more mouse buttons.</p> +<p>Click anywhere with one or more mouse buttons.</p> <pre id="log">buttons: </pre>JavaScript
-let log = document.createTextNode('?'); // let log = new Text('?'); +let log = document.createTextNode('?'); // let log = new Text('?'); function logButtons(e) { log.data = `${e.buttons} (${e.type})`; // log.nodeValue= `${e.buttons} (${e.type})`; diff --git a/files/en-us/web/api/mouseevent/clientx/index.html b/files/en-us/web/api/mouseevent/clientx/index.html index fcbc663526f849d..e3dae7e822edfa3 100644 --- a/files/en-us/web/api/mouseevent/clientx/index.html +++ b/files/en-us/web/api/mouseevent/clientx/index.html @@ -24,7 +24,7 @@Syntax
-var x = instanceOfMouseEvent.clientX +var x = instanceOfMouseEvent.clientXReturn value
@@ -40,12 +40,12 @@Example
HTML
-<p>Move your mouse to see its position.</p> +<p>Move your mouse to see its position.</p> <p id="screen-log"></p>JavaScript
-let screenLog = document.querySelector('#screen-log'); +let screenLog = document.querySelector('#screen-log'); document.addEventListener('mousemove', logKey); function logKey(e) { diff --git a/files/en-us/web/api/mouseevent/clienty/index.html b/files/en-us/web/api/mouseevent/clienty/index.html index 257fcf19c684a8b..6e81e5b14e323f5 100644 --- a/files/en-us/web/api/mouseevent/clienty/index.html +++ b/files/en-us/web/api/mouseevent/clienty/index.html @@ -23,7 +23,7 @@Syntax
-var y = instanceOfMouseEvent.clientY +var y = instanceOfMouseEvent.clientYReturn value
@@ -39,12 +39,12 @@Example
HTML
-<p>Move your mouse to see its position.</p> +<p>Move your mouse to see its position.</p> <p id="screen-log"></p>JavaScript
-let screenLog = document.querySelector('#screen-log'); +let screenLog = document.querySelector('#screen-log'); document.addEventListener('mousemove', logKey); function logKey(e) { diff --git a/files/en-us/web/api/mouseevent/ctrlkey/index.html b/files/en-us/web/api/mouseevent/ctrlkey/index.html index 77e658485609040..a6d4b041eb8b6ca 100644 --- a/files/en-us/web/api/mouseevent/ctrlkey/index.html +++ b/files/en-us/web/api/mouseevent/ctrlkey/index.html @@ -23,7 +23,7 @@Syntax
-var ctrlKeyPressed = instanceOfMouseEvent.ctrlKey +var ctrlKeyPressed = instanceOfMouseEvent.ctrlKeyReturn value
diff --git a/files/en-us/web/api/mouseevent/getmodifierstate/index.html b/files/en-us/web/api/mouseevent/getmodifierstate/index.html index 6dc200ce0746083..c7282ea50a75b44 100644 --- a/files/en-us/web/api/mouseevent/getmodifierstate/index.html +++ b/files/en-us/web/api/mouseevent/getmodifierstate/index.html @@ -23,7 +23,7 @@Syntax
var+ class="brush: js">varactive = event.getModifierState(keyArg);
active = event.getModifierState(keyArg);
Returns
diff --git a/files/en-us/web/api/mouseevent/index.html b/files/en-us/web/api/mouseevent/index.html index 653ba4e1388fb0b..cd54d75761ec0a7 100644 --- a/files/en-us/web/api/mouseevent/index.html +++ b/files/en-us/web/api/mouseevent/index.html @@ -111,12 +111,12 @@Example
HTML
-<p><label><input type="checkbox" id="checkbox"> Checked</label> +<p><label><input type="checkbox" id="checkbox"> Checked</label> <p><button id="button">Click me</button>JavaScript
-function simulateClick() { +function simulateClick() { var evt = new MouseEvent("click", { bubbles: true, cancelable: true, diff --git a/files/en-us/web/api/mouseevent/initmouseevent/index.html b/files/en-us/web/api/mouseevent/initmouseevent/index.html index 33a1a943d0dd6d9..ac70be51ac14347 100644 --- a/files/en-us/web/api/mouseevent/initmouseevent/index.html +++ b/files/en-us/web/api/mouseevent/initmouseevent/index.html @@ -32,7 +32,7 @@Syntax
-event.initMouseEvent(type, canBubble, cancelable, view, +event.initMouseEvent(type, canBubble, cancelable, view, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget);diff --git a/files/en-us/web/api/mouseevent/metakey/index.html b/files/en-us/web/api/mouseevent/metakey/index.html index cf24bc3f8405d1a..30fdd8fcce40fd2 100644 --- a/files/en-us/web/api/mouseevent/metakey/index.html +++ b/files/en-us/web/api/mouseevent/metakey/index.html @@ -27,7 +27,7 @@Syntax
-var metaKeyPressed = instanceOfMouseEvent.metaKey +var metaKeyPressed = instanceOfMouseEvent.metaKeyReturn value
diff --git a/files/en-us/web/api/mouseevent/mouseevent/index.html b/files/en-us/web/api/mouseevent/mouseevent/index.html index d81561d047e7306..e7039e5e8c952fd 100644 --- a/files/en-us/web/api/mouseevent/mouseevent/index.html +++ b/files/en-us/web/api/mouseevent/mouseevent/index.html @@ -17,7 +17,7 @@Syntax
event = new MouseEvent(typeArg, mouseEventInit);+ class="brush: js"> event = new MouseEvent(typeArg, mouseEventInit);Values
diff --git a/files/en-us/web/api/mouseevent/movementx/index.html b/files/en-us/web/api/mouseevent/movementx/index.html index b366561080b07c5..339080fde3d3a13 100644 --- a/files/en-us/web/api/mouseevent/movementx/index.html +++ b/files/en-us/web/api/mouseevent/movementx/index.html @@ -23,7 +23,7 @@Syntax
-var xShift = instanceOfMouseEvent.movementX; +var xShift = instanceOfMouseEvent.movementX;Return value
diff --git a/files/en-us/web/api/mouseevent/movementy/index.html b/files/en-us/web/api/mouseevent/movementy/index.html index ad6276f61c9e2cd..99fc5b290649cf9 100644 --- a/files/en-us/web/api/mouseevent/movementy/index.html +++ b/files/en-us/web/api/mouseevent/movementy/index.html @@ -23,7 +23,7 @@Syntax
-var yShift = instanceOfMouseEvent.movementY; +var yShift = instanceOfMouseEvent.movementY;Return value
diff --git a/files/en-us/web/api/mouseevent/mozinputsource/index.html b/files/en-us/web/api/mouseevent/mozinputsource/index.html index 8046f036944396b..ee96a81d0624eab 100644 --- a/files/en-us/web/api/mouseevent/mozinputsource/index.html +++ b/files/en-us/web/api/mouseevent/mozinputsource/index.html @@ -19,7 +19,7 @@Syntax
var source = instanceOfMouseEvent.mozInputSource;+ class="brush: js">var source = instanceOfMouseEvent.mozInputSource;Return value
diff --git a/files/en-us/web/api/mouseevent/offsetx/index.html b/files/en-us/web/api/mouseevent/offsetx/index.html index 1ddb05dc9d847f3..3f65383361d04d2 100644 --- a/files/en-us/web/api/mouseevent/offsetx/index.html +++ b/files/en-us/web/api/mouseevent/offsetx/index.html @@ -17,7 +17,7 @@Syntax
-var xOffset = instanceOfMouseEvent.offsetX; +var xOffset = instanceOfMouseEvent.offsetX;Return value
diff --git a/files/en-us/web/api/mouseevent/offsety/index.html b/files/en-us/web/api/mouseevent/offsety/index.html index 9e51ef39b81eb66..a91bbec1fb54355 100644 --- a/files/en-us/web/api/mouseevent/offsety/index.html +++ b/files/en-us/web/api/mouseevent/offsety/index.html @@ -17,7 +17,7 @@Syntax
-var yOffset = instanceOfMouseEvent.offsetY; +var yOffset = instanceOfMouseEvent.offsetY;Return value
diff --git a/files/en-us/web/api/mouseevent/pagex/index.html b/files/en-us/web/api/mouseevent/pagex/index.html index bcc00398670db52..584638236bf332d 100644 --- a/files/en-us/web/api/mouseevent/pagex/index.html +++ b/files/en-us/web/api/mouseevent/pagex/index.html @@ -38,7 +38,7 @@Syntax
var pageX = MouseEvent.pageX;+ class="brush: js">var pageX = MouseEvent.pageX;Value
diff --git a/files/en-us/web/api/mouseevent/pagey/index.html b/files/en-us/web/api/mouseevent/pagey/index.html index 10cb0eaeecd9776..d62c9bc8119d595 100644 --- a/files/en-us/web/api/mouseevent/pagey/index.html +++ b/files/en-us/web/api/mouseevent/pagey/index.html @@ -17,7 +17,7 @@Syntax
-var pos = event.pageY;+var pos = event.pageY;Originally, this property was defined as a
long
integer. The CSSOM View Module redefined it as adouble
float. See the Browser compatibility diff --git a/files/en-us/web/api/mouseevent/region/index.html b/files/en-us/web/api/mouseevent/region/index.html index 57d01fef2a2879e..84a347800ec5055 100644 --- a/files/en-us/web/api/mouseevent/region/index.html +++ b/files/en-us/web/api/mouseevent/region/index.html @@ -19,7 +19,7 @@Syntax
-var hitRegion = instanceOfMouseEvent.region +var hitRegion = instanceOfMouseEvent.regionReturn value
diff --git a/files/en-us/web/api/mouseevent/relatedtarget/index.html b/files/en-us/web/api/mouseevent/relatedtarget/index.html index 4ad9859de4efff6..df36bb6c8bf99b7 100644 --- a/files/en-us/web/api/mouseevent/relatedtarget/index.html +++ b/files/en-us/web/api/mouseevent/relatedtarget/index.html @@ -62,7 +62,7 @@Syntax
-var target = instanceOfMouseEvent.relatedTarget +var target = instanceOfMouseEvent.relatedTargetReturn value
diff --git a/files/en-us/web/api/mouseevent/screenx/index.html b/files/en-us/web/api/mouseevent/screenx/index.html index c92f6e6ef98c2f7..305f609043b3c81 100644 --- a/files/en-us/web/api/mouseevent/screenx/index.html +++ b/files/en-us/web/api/mouseevent/screenx/index.html @@ -18,7 +18,7 @@Syntax
-var x = instanceOfMouseEvent.screenX +var x = instanceOfMouseEvent.screenXReturn value
diff --git a/files/en-us/web/api/mouseevent/screeny/index.html b/files/en-us/web/api/mouseevent/screeny/index.html index c122adf11768aef..9c8ed4d4181bce1 100644 --- a/files/en-us/web/api/mouseevent/screeny/index.html +++ b/files/en-us/web/api/mouseevent/screeny/index.html @@ -17,7 +17,7 @@Syntax
-var y = instanceOfMouseEvent.screenY +var y = instanceOfMouseEvent.screenYReturn value
diff --git a/files/en-us/web/api/mouseevent/shiftkey/index.html b/files/en-us/web/api/mouseevent/shiftkey/index.html index 534ab5d350e6f8d..f1e66b592bac7be 100644 --- a/files/en-us/web/api/mouseevent/shiftkey/index.html +++ b/files/en-us/web/api/mouseevent/shiftkey/index.html @@ -18,7 +18,7 @@Syntax
-var shiftKeyPressed = instanceOfMouseEvent.shiftKey +var shiftKeyPressed = instanceOfMouseEvent.shiftKeyReturn value
diff --git a/files/en-us/web/api/mouseevent/which/index.html b/files/en-us/web/api/mouseevent/which/index.html index dd86c3dadd4000a..52ecab19dd1c68c 100644 --- a/files/en-us/web/api/mouseevent/which/index.html +++ b/files/en-us/web/api/mouseevent/which/index.html @@ -21,7 +21,7 @@Syntax
-var buttonPressed = instanceOfMouseEvent.which +var buttonPressed = instanceOfMouseEvent.whichReturn value
diff --git a/files/en-us/web/api/networkinformation/downlink/index.html b/files/en-us/web/api/networkinformation/downlink/index.html index 1a887a6c90d1f43..3581ab58f5a0b6f 100644 --- a/files/en-us/web/api/networkinformation/downlink/index.html +++ b/files/en-us/web/api/networkinformation/downlink/index.html @@ -28,7 +28,7 @@Syntax
var downLink = NetworkInformation.downlink+ class="brush: js">var downLink = NetworkInformation.downlinkValue
diff --git a/files/en-us/web/api/networkinformation/downlinkmax/index.html b/files/en-us/web/api/networkinformation/downlinkmax/index.html index 7b5f8db25de5aef..3ab4c843986ccb9 100644 --- a/files/en-us/web/api/networkinformation/downlinkmax/index.html +++ b/files/en-us/web/api/networkinformation/downlinkmax/index.html @@ -21,7 +21,7 @@Syntax
var max = NetworkInformation.downlinkMax+ class="brush: js">var max = NetworkInformation.downlinkMaxReturn value
diff --git a/files/en-us/web/api/networkinformation/effectivetype/index.html b/files/en-us/web/api/networkinformation/effectivetype/index.html index 70c37fe2c25e531..db1a7bef1528c0c 100644 --- a/files/en-us/web/api/networkinformation/effectivetype/index.html +++ b/files/en-us/web/api/networkinformation/effectivetype/index.html @@ -19,7 +19,7 @@Syntax
var effectiveType = NetworkInformation.effectiveType+ class="brush: js">var effectiveType = NetworkInformation.effectiveTypeValue
diff --git a/files/en-us/web/api/networkinformation/onchange/index.html b/files/en-us/web/api/networkinformation/onchange/index.html index e4256979d109cf4..5f1cca8bbdc3ad2 100644 --- a/files/en-us/web/api/networkinformation/onchange/index.html +++ b/files/en-us/web/api/networkinformation/onchange/index.html @@ -18,7 +18,7 @@Syntax
-netInfo.onchange = function() { ... } +netInfo.onchange = function() { ... }Examples
diff --git a/files/en-us/web/api/networkinformation/rtt/index.html b/files/en-us/web/api/networkinformation/rtt/index.html index 07e684c0ce72774..aaa8e5766cca145 100644 --- a/files/en-us/web/api/networkinformation/rtt/index.html +++ b/files/en-us/web/api/networkinformation/rtt/index.html @@ -24,7 +24,7 @@Syntax
-rtt = NetworkInformation.rtt+rtt = NetworkInformation.rttReturn value
diff --git a/files/en-us/web/api/networkinformation/savedata/index.html b/files/en-us/web/api/networkinformation/savedata/index.html index e297e7a05929369..683a7a15b421168 100644 --- a/files/en-us/web/api/networkinformation/savedata/index.html +++ b/files/en-us/web/api/networkinformation/savedata/index.html @@ -20,7 +20,7 @@Syntax
var saveData = NetworkInformation.saveData;+ class="brush: js">var saveData = NetworkInformation.saveData;Value
diff --git a/files/en-us/web/api/networkinformation/type/index.html b/files/en-us/web/api/networkinformation/type/index.html index 199c816e1534905..c7ef294796a5c62 100644 --- a/files/en-us/web/api/networkinformation/type/index.html +++ b/files/en-us/web/api/networkinformation/type/index.html @@ -19,7 +19,7 @@Syntax
-var type = netInfo.type+var type = netInfo.typeReturn value
diff --git a/files/en-us/web/api/nodeiterator/detach/index.html b/files/en-us/web/api/nodeiterator/detach/index.html index eb2c5fe318fdc49..4fdef30bfa664af 100644 --- a/files/en-us/web/api/nodeiterator/detach/index.html +++ b/files/en-us/web/api/nodeiterator/detach/index.html @@ -21,7 +21,7 @@Syntax
-nodeIterator.detach(); +nodeIterator.detach();Example
diff --git a/files/en-us/web/api/nodeiterator/expandentityreferences/index.html b/files/en-us/web/api/nodeiterator/expandentityreferences/index.html index da1cef7638c733e..ac1b7070a4c31f7 100644 --- a/files/en-us/web/api/nodeiterator/expandentityreferences/index.html +++ b/files/en-us/web/api/nodeiterator/expandentityreferences/index.html @@ -20,7 +20,7 @@Syntax
-expand = nodeIterator.expandEntityReferences; +expand = nodeIterator.expandEntityReferences;Example
diff --git a/files/en-us/web/api/nodeiterator/filter/index.html b/files/en-us/web/api/nodeiterator/filter/index.html index 67d5b8864436829..222d7ddf9d2eec2 100644 --- a/files/en-us/web/api/nodeiterator/filter/index.html +++ b/files/en-us/web/api/nodeiterator/filter/index.html @@ -22,7 +22,7 @@Syntax
-nodeFilter = nodeIterator.filter; +nodeFilter = nodeIterator.filter;Example
diff --git a/files/en-us/web/api/nodeiterator/index.html b/files/en-us/web/api/nodeiterator/index.html index be3b2a966eab616..8d0ffca906e75ff 100644 --- a/files/en-us/web/api/nodeiterator/index.html +++ b/files/en-us/web/api/nodeiterator/index.html @@ -17,7 +17,7 @@Syntax
{{domxref("Document.createNodeIterator()")}} method, as follows:const nodeIterator = document.createNodeIterator(root, whatToShow, filter);+ class="brush: js">const nodeIterator = document.createNodeIterator(root, whatToShow, filter);Properties
diff --git a/files/en-us/web/api/nodeiterator/nextnode/index.html b/files/en-us/web/api/nodeiterator/nextnode/index.html index 5d2ac10312d7a2b..bedcfd46229a810 100644 --- a/files/en-us/web/api/nodeiterator/nextnode/index.html +++ b/files/en-us/web/api/nodeiterator/nextnode/index.html @@ -23,7 +23,7 @@Syntax
-node = nodeIterator.nextNode(); +node = nodeIterator.nextNode();Example
diff --git a/files/en-us/web/api/nodeiterator/pointerbeforereferencenode/index.html b/files/en-us/web/api/nodeiterator/pointerbeforereferencenode/index.html index 73af7cb92c7166a..ec1ecd210cfbd94 100644 --- a/files/en-us/web/api/nodeiterator/pointerbeforereferencenode/index.html +++ b/files/en-us/web/api/nodeiterator/pointerbeforereferencenode/index.html @@ -19,7 +19,7 @@Syntax
-flag = nodeIterator.pointerBeforeReferenceNode; +flag = nodeIterator.pointerBeforeReferenceNode;Example
diff --git a/files/en-us/web/api/nodeiterator/previousnode/index.html b/files/en-us/web/api/nodeiterator/previousnode/index.html index 12b6ea93bb8223b..f32070b7f2d9632 100644 --- a/files/en-us/web/api/nodeiterator/previousnode/index.html +++ b/files/en-us/web/api/nodeiterator/previousnode/index.html @@ -23,7 +23,7 @@Syntax
-node = nodeIterator.previousNode(); +node = nodeIterator.previousNode();Example
diff --git a/files/en-us/web/api/nodeiterator/referencenode/index.html b/files/en-us/web/api/nodeiterator/referencenode/index.html index 0f736efc8f29d8e..02dfa4faa2993df 100644 --- a/files/en-us/web/api/nodeiterator/referencenode/index.html +++ b/files/en-us/web/api/nodeiterator/referencenode/index.html @@ -17,7 +17,7 @@Syntax
-node = nodeIterator.referenceNode; +node = nodeIterator.referenceNode;Example
diff --git a/files/en-us/web/api/nodeiterator/root/index.html b/files/en-us/web/api/nodeiterator/root/index.html index ee87250844e2541..df5e88821c0427f 100644 --- a/files/en-us/web/api/nodeiterator/root/index.html +++ b/files/en-us/web/api/nodeiterator/root/index.html @@ -15,7 +15,7 @@Syntax
-root = nodeIterator.root; +root = nodeIterator.root;Example
diff --git a/files/en-us/web/api/nodeiterator/whattoshow/index.html b/files/en-us/web/api/nodeiterator/whattoshow/index.html index dc20be0ae8c439c..e91ac0ddb8131fc 100644 --- a/files/en-us/web/api/nodeiterator/whattoshow/index.html +++ b/files/en-us/web/api/nodeiterator/whattoshow/index.html @@ -15,7 +15,7 @@Syntax
-var nodeTypes = nodeIterator.whatToShow; +var nodeTypes = nodeIterator.whatToShow;The values that can be combined to form the bitmask are:
diff --git a/files/en-us/web/api/ovr_multiview2/framebuffertexturemultiviewovr/index.html b/files/en-us/web/api/ovr_multiview2/framebuffertexturemultiviewovr/index.html index 65f86c022edc84e..7d8dd1e9b43d332 100644 --- a/files/en-us/web/api/ovr_multiview2/framebuffertexturemultiviewovr/index.html +++ b/files/en-us/web/api/ovr_multiview2/framebuffertexturemultiviewovr/index.html @@ -19,7 +19,7 @@Syntax
-void ext.framebufferTextureMultiviewOVR(target, attachment, texture, level, baseViewIndex, numViews); +void ext.framebufferTextureMultiviewOVR(target, attachment, texture, level, baseViewIndex, numViews);Parameters
diff --git a/files/en-us/web/api/pannernode/orientationx/index.html b/files/en-us/web/api/pannernode/orientationx/index.html index 666c11a92b98e4b..1d391ae811422ab 100644 --- a/files/en-us/web/api/pannernode/orientationx/index.html +++ b/files/en-us/web/api/pannernode/orientationx/index.html @@ -38,7 +38,7 @@Syntax
-var orientationX = PannerNode.orientationX; +var orientationX = PannerNode.orientationX; PannerNode.orientationX.value = newOrientationX;diff --git a/files/en-us/web/api/pannernode/orientationy/index.html b/files/en-us/web/api/pannernode/orientationy/index.html index 0bbb94d69d176c6..da8c5e385df2dbd 100644 --- a/files/en-us/web/api/pannernode/orientationy/index.html +++ b/files/en-us/web/api/pannernode/orientationy/index.html @@ -39,7 +39,7 @@Syntax
-var orientationY = PannerNode.orientationY; +var orientationY = PannerNode.orientationY; PannerNode.orientationY.value = newOrientationY;diff --git a/files/en-us/web/api/pannernode/orientationz/index.html b/files/en-us/web/api/pannernode/orientationz/index.html index 1709096f2d2eae7..4986392080df6ca 100644 --- a/files/en-us/web/api/pannernode/orientationz/index.html +++ b/files/en-us/web/api/pannernode/orientationz/index.html @@ -37,7 +37,7 @@Syntax
-var orientationZ = PannerNode.orientationZ; +var orientationZ = PannerNode.orientationZ; PannerNode.orientationZ.value = newOrientationZ;diff --git a/files/en-us/web/api/pannernode/positionx/index.html b/files/en-us/web/api/pannernode/positionx/index.html index 632806a13eb1bf6..77ed4ab77858fd6 100644 --- a/files/en-us/web/api/pannernode/positionx/index.html +++ b/files/en-us/web/api/pannernode/positionx/index.html @@ -39,7 +39,7 @@Syntax
-var positionX = PannerNode.positionX; +var positionX = PannerNode.positionX; PannerNode.positionX.value = newPositionX;diff --git a/files/en-us/web/api/pannernode/positiony/index.html b/files/en-us/web/api/pannernode/positiony/index.html index e0229c2130ba152..2a85806228db4b2 100644 --- a/files/en-us/web/api/pannernode/positiony/index.html +++ b/files/en-us/web/api/pannernode/positiony/index.html @@ -38,7 +38,7 @@Syntax
-var positionY = PannerNode.positionY; +var positionY = PannerNode.positionY; PannerNode.positionY.value = newPositionY;diff --git a/files/en-us/web/api/pannernode/positionz/index.html b/files/en-us/web/api/pannernode/positionz/index.html index 7ae310c0ccaef89..734fea755625492 100644 --- a/files/en-us/web/api/pannernode/positionz/index.html +++ b/files/en-us/web/api/pannernode/positionz/index.html @@ -38,7 +38,7 @@Syntax
-var positionZ = PannerNode.positionZ; +var positionZ = PannerNode.positionZ; PannerNode.positionZ.value = newPositionZ;diff --git a/files/en-us/web/api/paymentaddress/addressline/index.html b/files/en-us/web/api/paymentaddress/addressline/index.html index 2e804cf8e8c82d0..5625504c98b3479 100644 --- a/files/en-us/web/api/paymentaddress/addressline/index.html +++ b/files/en-us/web/api/paymentaddress/addressline/index.html @@ -25,7 +25,7 @@Syntax
var paymentAddressLines = PaymentAddress.addressLine;+ class="brush: js">var paymentAddressLines = PaymentAddress.addressLine;Value
diff --git a/files/en-us/web/api/paymentaddress/city/index.html b/files/en-us/web/api/paymentaddress/city/index.html index c95e3fb9ec7ce9c..9d640d956222753 100644 --- a/files/en-us/web/api/paymentaddress/city/index.html +++ b/files/en-us/web/api/paymentaddress/city/index.html @@ -25,7 +25,7 @@Syntax
var paymentCity = PaymentAddress.city;+ class="brush: js">var paymentCity = PaymentAddress.city;Value
diff --git a/files/en-us/web/api/paymentaddress/country/index.html b/files/en-us/web/api/paymentaddress/country/index.html index 84b5a4340c8ab0b..57438b76934f343 100644 --- a/files/en-us/web/api/paymentaddress/country/index.html +++ b/files/en-us/web/api/paymentaddress/country/index.html @@ -26,7 +26,7 @@Syntax
var paymentCountry = PaymentAddress.country;+ class="brush: js">var paymentCountry = PaymentAddress.country;Value
diff --git a/files/en-us/web/api/paymentaddress/dependentlocality/index.html b/files/en-us/web/api/paymentaddress/dependentlocality/index.html index a94f39eef188076..8fa70b51751afc9 100644 --- a/files/en-us/web/api/paymentaddress/dependentlocality/index.html +++ b/files/en-us/web/api/paymentaddress/dependentlocality/index.html @@ -21,7 +21,7 @@Syntax
var paymentDependentLocality = PaymentAddress.dependentLocality;+ class="brush: js">var paymentDependentLocality = PaymentAddress.dependentLocality;Value
diff --git a/files/en-us/web/api/paymentaddress/languagecode/index.html b/files/en-us/web/api/paymentaddress/languagecode/index.html index 7fafea973f9f447..a2be77c452a33ba 100644 --- a/files/en-us/web/api/paymentaddress/languagecode/index.html +++ b/files/en-us/web/api/paymentaddress/languagecode/index.html @@ -29,7 +29,7 @@Syntax
var paymentLanguageCode = PaymentAddress.languageCode;+ class="brush: js">var paymentLanguageCode = PaymentAddress.languageCode;Value
diff --git a/files/en-us/web/api/paymentaddress/organization/index.html b/files/en-us/web/api/paymentaddress/organization/index.html index f97b311683f7fe1..60530163c5f931f 100644 --- a/files/en-us/web/api/paymentaddress/organization/index.html +++ b/files/en-us/web/api/paymentaddress/organization/index.html @@ -25,7 +25,7 @@Syntax
var paymentOrganization = PaymentAddress.organization;+ class="brush: js">var paymentOrganization = PaymentAddress.organization;Value
diff --git a/files/en-us/web/api/paymentaddress/phone/index.html b/files/en-us/web/api/paymentaddress/phone/index.html index bdd62b3b9da94d8..ca27ec6a6888fc7 100644 --- a/files/en-us/web/api/paymentaddress/phone/index.html +++ b/files/en-us/web/api/paymentaddress/phone/index.html @@ -25,7 +25,7 @@Syntax
var paymentPhone = PaymentAddress.phone;+ class="brush: js">var paymentPhone = PaymentAddress.phone;Value
diff --git a/files/en-us/web/api/paymentaddress/postalcode/index.html b/files/en-us/web/api/paymentaddress/postalcode/index.html index 50f36ba62195ec8..b7dc5b4211ae4d6 100644 --- a/files/en-us/web/api/paymentaddress/postalcode/index.html +++ b/files/en-us/web/api/paymentaddress/postalcode/index.html @@ -31,7 +31,7 @@Syntax
var paymentPostalCode = PaymentAddress.postalCode;+ class="brush: js">var paymentPostalCode = PaymentAddress.postalCode;Value
diff --git a/files/en-us/web/api/paymentaddress/recipient/index.html b/files/en-us/web/api/paymentaddress/recipient/index.html index 44f6742592e063c..51215fd18d936b9 100644 --- a/files/en-us/web/api/paymentaddress/recipient/index.html +++ b/files/en-us/web/api/paymentaddress/recipient/index.html @@ -19,7 +19,7 @@Syntax
var paymentRecipient = PaymentAddress.recipient;+ class="brush: js">var paymentRecipient = PaymentAddress.recipient;Value
diff --git a/files/en-us/web/api/paymentaddress/region/index.html b/files/en-us/web/api/paymentaddress/region/index.html index 8a69cc6097d0d98..55d0a8fd05f9c3d 100644 --- a/files/en-us/web/api/paymentaddress/region/index.html +++ b/files/en-us/web/api/paymentaddress/region/index.html @@ -28,7 +28,7 @@Syntax
var paymentRegion = PaymentAddress.region;+ class="brush: js">var paymentRegion = PaymentAddress.region;Value
diff --git a/files/en-us/web/api/paymentaddress/regioncode/index.html b/files/en-us/web/api/paymentaddress/regioncode/index.html index b429e1bae5313f5..6097d6368b2bc57 100644 --- a/files/en-us/web/api/paymentaddress/regioncode/index.html +++ b/files/en-us/web/api/paymentaddress/regioncode/index.html @@ -35,7 +35,7 @@Syntax
var regionCode = paymentAddress.regionCode;+ class="brush: js">var regionCode = paymentAddress.regionCode;Value
diff --git a/files/en-us/web/api/paymentaddress/sortingcode/index.html b/files/en-us/web/api/paymentaddress/sortingcode/index.html index 8c786d40e49b77c..772a8c8b771e400 100644 --- a/files/en-us/web/api/paymentaddress/sortingcode/index.html +++ b/files/en-us/web/api/paymentaddress/sortingcode/index.html @@ -23,7 +23,7 @@Syntax
var sortingCode = PaymentAddress.sortingCode;+ class="brush: js">var sortingCode = PaymentAddress.sortingCode;Value
diff --git a/files/en-us/web/api/paymentaddress/tojson/index.html b/files/en-us/web/api/paymentaddress/tojson/index.html index fa3b9c62f68dacb..0bb46b2b1a3fb8b 100644 --- a/files/en-us/web/api/paymentaddress/tojson/index.html +++ b/files/en-us/web/api/paymentaddress/tojson/index.html @@ -20,7 +20,7 @@Syntax
var json = PaymentAddress.toJSON()+ class="brush: js">var json = PaymentAddress.toJSON()Parameters
diff --git a/files/en-us/web/api/pictureinpicturewindow/height/index.html b/files/en-us/web/api/pictureinpicturewindow/height/index.html index 38e2fb6eaac7120..65039568ad5f1c0 100644 --- a/files/en-us/web/api/pictureinpicturewindow/height/index.html +++ b/files/en-us/web/api/pictureinpicturewindow/height/index.html @@ -18,7 +18,7 @@Syntax
-let height = pictureInPictureWindow.height;+let height = pictureInPictureWindow.height;Value
diff --git a/files/en-us/web/api/pictureinpicturewindow/index.html b/files/en-us/web/api/pictureinpicturewindow/index.html index 4f0ffebdc623e36..fd6fb056ba74427 100644 --- a/files/en-us/web/api/pictureinpicturewindow/index.html +++ b/files/en-us/web/api/pictureinpicturewindow/index.html @@ -45,7 +45,7 @@Examples
Given a
-<button>
and a<video>
, clicking the button will make the video enter the picture-in-picture mode; we then attach an event to print the floating video window dimensions to the console.const button = document.querySelector("button"); +const button = document.querySelector("button"); const video = document.querySelector("video"); function printPipWindowDimensions(evt) { diff --git a/files/en-us/web/api/pictureinpicturewindow/onresize/index.html b/files/en-us/web/api/pictureinpicturewindow/onresize/index.html index fb2799d0aefac46..76abfcbd5fb7b3f 100644 --- a/files/en-us/web/api/pictureinpicturewindow/onresize/index.html +++ b/files/en-us/web/api/pictureinpicturewindow/onresize/index.html @@ -22,7 +22,7 @@Syntax
-pictureInPictureWindow.onresize = functionRef; +pictureInPictureWindow.onresize = functionRef;Value
@@ -36,13 +36,13 @@Examples
Window size logger
-<p>Resize the floating video window to fire the <code>resize</code> event.</p> +<p>Resize the floating video window to fire the <code>resize</code> event.</p> <p>Window height: <span id="height"></span></p> <p>Window width: <span id="width"></span></p> <video id="video" muted autoplay src=""></video>-const video = document.querySelector('#video'); +const video = document.querySelector('#video'); const heightOutput = document.querySelector('#height'); const widthOutput = document.querySelector('#width'); diff --git a/files/en-us/web/api/pictureinpicturewindow/resize_event/index.html b/files/en-us/web/api/pictureinpicturewindow/resize_event/index.html index e5a7cfcfec8363a..5dcae5dfc3712a1 100644 --- a/files/en-us/web/api/pictureinpicturewindow/resize_event/index.html +++ b/files/en-us/web/api/pictureinpicturewindow/resize_event/index.html @@ -39,13 +39,13 @@Examples
Window size logger
-<p>Resize the floating video window to fire the <code>resize</code> event.</p> +<p>Resize the floating video window to fire the <code>resize</code> event.</p> <p>Window height: <span id="height"></span></p> <p>Window width: <span id="width"></span></p> <video id="video" src="" muted autoplay></video>-const video = document.querySelector('#video'); +const video = document.querySelector('#video'); const heightOutput = document.querySelector('#height'); const widthOutput = document.querySelector('#width'); @@ -63,7 +63,7 @@addEventListener equivalent
You could set up the event handler using the
-addEventListener()
method:pictureInPictureWindow.addEventListener('resize', resize);+pictureInPictureWindow.addEventListener('resize', resize);Specifications
diff --git a/files/en-us/web/api/pictureinpicturewindow/width/index.html b/files/en-us/web/api/pictureinpicturewindow/width/index.html index 9bd6e65d48072c8..5f19945900a7a62 100644 --- a/files/en-us/web/api/pictureinpicturewindow/width/index.html +++ b/files/en-us/web/api/pictureinpicturewindow/width/index.html @@ -18,7 +18,7 @@Syntax
-let width = pictureInPictureWindow.width;+let width = pictureInPictureWindow.width;Value
diff --git a/files/en-us/web/api/pointerevent/getcoalescedevents/index.html b/files/en-us/web/api/pointerevent/getcoalescedevents/index.html index 3f13f11a3e7d348..843bd7af5a651bd 100644 --- a/files/en-us/web/api/pointerevent/getcoalescedevents/index.html +++ b/files/en-us/web/api/pointerevent/getcoalescedevents/index.html @@ -19,7 +19,7 @@Syntax
var pointerEvents[] = PointerEvent.getCoalescedEvents()+ class="brush: js">var pointerEvents[] = PointerEvent.getCoalescedEvents()Parameters
diff --git a/files/en-us/web/api/pointerevent/height/index.html b/files/en-us/web/api/pointerevent/height/index.html index 30f5aa5c2b66b98..769c3530650f936 100644 --- a/files/en-us/web/api/pointerevent/height/index.html +++ b/files/en-us/web/api/pointerevent/height/index.html @@ -22,7 +22,7 @@Syntax
-var contactHeight = pointerEvent.height; +var contactHeight = pointerEvent.height;Return value
diff --git a/files/en-us/web/api/pointerevent/isprimary/index.html b/files/en-us/web/api/pointerevent/isprimary/index.html index f60d89d98deb489..fae7222eca2cfc5 100644 --- a/files/en-us/web/api/pointerevent/isprimary/index.html +++ b/files/en-us/web/api/pointerevent/isprimary/index.html @@ -40,7 +40,7 @@Syntax
-var isPrimary = pointerEvent.isPrimary; +var isPrimary = pointerEvent.isPrimary;Return value
@@ -56,7 +56,7 @@Example
This example illustrates using the value of
-isPrimary
to call the appropriate processing function.target.addEventListener('pointerdown', function(event) { +target.addEventListener('pointerdown', function(event) { if (event.isPrimary) process_primary_pointer(event); else diff --git a/files/en-us/web/api/pointerevent/pointerevent/index.html b/files/en-us/web/api/pointerevent/pointerevent/index.html index cec619f00bbdfa0..632f2fa6d240494 100644 --- a/files/en-us/web/api/pointerevent/pointerevent/index.html +++ b/files/en-us/web/api/pointerevent/pointerevent/index.html @@ -15,7 +15,7 @@Syntax
event = new PointerEvent(type, PointerEventInit);+ class="brush: js"> event = new PointerEvent(type, PointerEventInit);Arguments
diff --git a/files/en-us/web/api/pointerevent/pointerid/index.html b/files/en-us/web/api/pointerevent/pointerid/index.html index 9c6ef2fcf7afca5..935548a288595e2 100644 --- a/files/en-us/web/api/pointerevent/pointerid/index.html +++ b/files/en-us/web/api/pointerevent/pointerid/index.html @@ -19,7 +19,7 @@Syntax
-var id = pointerEvent.pointerId; +var id = pointerEvent.pointerId;Return value
diff --git a/files/en-us/web/api/pointerevent/pointertype/index.html b/files/en-us/web/api/pointerevent/pointertype/index.html index 33ae99989c3ef5d..b2793207d5351a9 100644 --- a/files/en-us/web/api/pointerevent/pointertype/index.html +++ b/files/en-us/web/api/pointerevent/pointertype/index.html @@ -17,7 +17,7 @@Syntax
-var pType = pointerEvent.pointerType; +var pType = pointerEvent.pointerType;Return value
diff --git a/files/en-us/web/api/pointerevent/pressure/index.html b/files/en-us/web/api/pointerevent/pressure/index.html index bd8aba68672a8fe..9c8404a5afeda13 100644 --- a/files/en-us/web/api/pointerevent/pressure/index.html +++ b/files/en-us/web/api/pointerevent/pressure/index.html @@ -17,7 +17,7 @@Syntax
-var pressure = pointerEvent.pressure; +var pressure = pointerEvent.pressure;Return value
diff --git a/files/en-us/web/api/pointerevent/tangentialpressure/index.html b/files/en-us/web/api/pointerevent/tangentialpressure/index.html index ec5c19ce824cce0..9355b7c4abdb727 100644 --- a/files/en-us/web/api/pointerevent/tangentialpressure/index.html +++ b/files/en-us/web/api/pointerevent/tangentialpressure/index.html @@ -19,7 +19,7 @@Syntax
-var tanPressure = pointerEvent.tangentialPressure; +var tanPressure = pointerEvent.tangentialPressure;Return value
diff --git a/files/en-us/web/api/pointerevent/tiltx/index.html b/files/en-us/web/api/pointerevent/tiltx/index.html index ca49b12d008ae51..8817ffbd4e838bf 100644 --- a/files/en-us/web/api/pointerevent/tiltx/index.html +++ b/files/en-us/web/api/pointerevent/tiltx/index.html @@ -22,7 +22,7 @@Syntax
-var tiltX = pointerEvent.tiltX; +var tiltX = pointerEvent.tiltX;Return value
diff --git a/files/en-us/web/api/pointerevent/tilty/index.html b/files/en-us/web/api/pointerevent/tilty/index.html index 489d0d66cb1f2cb..e319c59a07c200a 100644 --- a/files/en-us/web/api/pointerevent/tilty/index.html +++ b/files/en-us/web/api/pointerevent/tilty/index.html @@ -22,7 +22,7 @@Syntax
-var tiltY = pointerEvent.tiltY; +var tiltY = pointerEvent.tiltY;Return value
diff --git a/files/en-us/web/api/pointerevent/twist/index.html b/files/en-us/web/api/pointerevent/twist/index.html index d368db2035cc646..ce1b3744137f86d 100644 --- a/files/en-us/web/api/pointerevent/twist/index.html +++ b/files/en-us/web/api/pointerevent/twist/index.html @@ -18,7 +18,7 @@Syntax
-var twist = pointerEvent.twist; +var twist = pointerEvent.twist;Return value
diff --git a/files/en-us/web/api/pointerevent/width/index.html b/files/en-us/web/api/pointerevent/width/index.html index fd73b68edee40bf..2e90db3c3c0e180 100644 --- a/files/en-us/web/api/pointerevent/width/index.html +++ b/files/en-us/web/api/pointerevent/width/index.html @@ -22,7 +22,7 @@Syntax
-var contactWidth = pointerEvent.width; +var contactWidth = pointerEvent.width;Return value
diff --git a/files/en-us/web/api/reportingobserver/disconnect/index.html b/files/en-us/web/api/reportingobserver/disconnect/index.html index 49e63f4d3521981..5026b519906af71 100644 --- a/files/en-us/web/api/reportingobserver/disconnect/index.html +++ b/files/en-us/web/api/reportingobserver/disconnect/index.html @@ -23,7 +23,7 @@Syntax
-reportingObserverInstance.disconnect() +reportingObserverInstance.disconnect()Examples
diff --git a/files/en-us/web/api/reportingobserver/observe/index.html b/files/en-us/web/api/reportingobserver/observe/index.html index 22b1a307f755cbe..d9650ee56e902a9 100644 --- a/files/en-us/web/api/reportingobserver/observe/index.html +++ b/files/en-us/web/api/reportingobserver/observe/index.html @@ -18,7 +18,7 @@Syntax
-reportingObserverInstance.observe() +reportingObserverInstance.observe()Examples
diff --git a/files/en-us/web/api/reportingobserver/reportingobserver/index.html b/files/en-us/web/api/reportingobserver/reportingobserver/index.html index 683e0de33b93aed..f78c14a44812b50 100644 --- a/files/en-us/web/api/reportingobserver/reportingobserver/index.html +++ b/files/en-us/web/api/reportingobserver/reportingobserver/index.html @@ -18,7 +18,7 @@Syntax
-new ReportingObserver(callback[, options]); +new ReportingObserver(callback[, options]);Parameters
diff --git a/files/en-us/web/api/reportingobserver/takerecords/index.html b/files/en-us/web/api/reportingobserver/takerecords/index.html index 47e351ea461151a..60ee71fe510af7f 100644 --- a/files/en-us/web/api/reportingobserver/takerecords/index.html +++ b/files/en-us/web/api/reportingobserver/takerecords/index.html @@ -17,7 +17,7 @@Syntax
-reportingObserverInstance.takeRecords() +reportingObserverInstance.takeRecords()Return value
diff --git a/files/en-us/web/api/rtcpeerconnectioniceerrorevent/address/index.html b/files/en-us/web/api/rtcpeerconnectioniceerrorevent/address/index.html index 843e4c45871af70..3b2c86270c44280 100644 --- a/files/en-us/web/api/rtcpeerconnectioniceerrorevent/address/index.html +++ b/files/en-us/web/api/rtcpeerconnectioniceerrorevent/address/index.html @@ -25,7 +25,7 @@Syntax
let address = rtcPeerConnectionIceErrorEvent.address;+ class="brush: js">let address = rtcPeerConnectionIceErrorEvent.address;Value
@@ -52,7 +52,7 @@Examples
{{domxref("RTCPeerConnectionIceErrorEvent.errorText", "errorText")}} property's contents. -pc.addEventListener("icecandidateerror", (event) => { +pc.addEventListener("icecandidateerror", (event) => { let networkInfo = `[Local interface: ${event.address}:${event.port}`; let iceServerInfo = `[ICE server: ${event.url}`; diff --git a/files/en-us/web/api/rtcsessiondescription/rtcsessiondescription/index.html b/files/en-us/web/api/rtcsessiondescription/rtcsessiondescription/index.html index a082647f1ee9058..aae6e6b76c087f9 100644 --- a/files/en-us/web/api/rtcsessiondescription/rtcsessiondescription/index.html +++ b/files/en-us/web/api/rtcsessiondescription/rtcsessiondescription/index.html @@ -28,7 +28,7 @@Syntax
sessionDescription = new RTCSessionDescription(rtcSessionDescriptionInit);+ class="brush: js"> sessionDescription = new RTCSessionDescription(rtcSessionDescriptionInit);Values
diff --git a/files/en-us/web/api/rtcsessiondescription/sdp/index.html b/files/en-us/web/api/rtcsessiondescription/sdp/index.html index 048aa464329ad06..1393a8c552f5327 100644 --- a/files/en-us/web/api/rtcsessiondescription/sdp/index.html +++ b/files/en-us/web/api/rtcsessiondescription/sdp/index.html @@ -17,7 +17,7 @@Syntax
-var value = sessionDescription.sdp; +var value = sessionDescription.sdp; sessionDescription.sdp = value;diff --git a/files/en-us/web/api/rtcsessiondescription/tojson/index.html b/files/en-us/web/api/rtcsessiondescription/tojson/index.html index fd2e048e0d702ad..78dd3e14e819f83 100644 --- a/files/en-us/web/api/rtcsessiondescription/tojson/index.html +++ b/files/en-us/web/api/rtcsessiondescription/tojson/index.html @@ -21,7 +21,7 @@Syntax
-var jsonValue = sd.toJSON(); +
var jsonValue = sd.toJSON();
The result value is a {{jsxref("JSON")}} object containing the following values:
diff --git a/files/en-us/web/api/rtcsessiondescription/type/index.html b/files/en-us/web/api/rtcsessiondescription/type/index.html index 8ef701abcdba459..356b788244bf8bd 100644 --- a/files/en-us/web/api/rtcsessiondescription/type/index.html +++ b/files/en-us/web/api/rtcsessiondescription/type/index.html @@ -17,7 +17,7 @@Syntax
-var value = sessionDescription.type; +var value = sessionDescription.type; sessionDescription.type = value;diff --git a/files/en-us/web/api/sharedworker/port/index.html b/files/en-us/web/api/sharedworker/port/index.html index 2f41791f54c3566..01e3379531854ae 100644 --- a/files/en-us/web/api/sharedworker/port/index.html +++ b/files/en-us/web/api/sharedworker/port/index.html @@ -17,7 +17,7 @@Syntax
-myWorker.port;+myWorker.port;Value
diff --git a/files/en-us/web/api/sharedworker/sharedworker/index.html b/files/en-us/web/api/sharedworker/sharedworker/index.html index 9872d256755b8e7..d93107e895ae6b8 100644 --- a/files/en-us/web/api/sharedworker/sharedworker/index.html +++ b/files/en-us/web/api/sharedworker/sharedworker/index.html @@ -24,7 +24,7 @@Syntax
-var myWorker = new SharedWorker(aURL, name); +var myWorker = new SharedWorker(aURL, name); var myWorker = new SharedWorker(aURL, options);Parameters
@@ -79,7 +79,7 @@Examples
The following code snippet shows creation of a {{domxref("SharedWorker")}} object using the
-SharedWorker()
constructor and subsequent usage of the object:var myWorker = new SharedWorker('worker.js'); +var myWorker = new SharedWorker('worker.js'); myWorker.port.start(); diff --git a/files/en-us/web/api/storageestimate/quota/index.html b/files/en-us/web/api/storageestimate/quota/index.html index f222b0280dc33e5..f31060d36c8dabf 100644 --- a/files/en-us/web/api/storageestimate/quota/index.html +++ b/files/en-us/web/api/storageestimate/quota/index.html @@ -21,7 +21,7 @@Syntax
-quota = StorageEstimate.quota; +quota = StorageEstimate.quota;Value
diff --git a/files/en-us/web/api/storageestimate/usage/index.html b/files/en-us/web/api/storageestimate/usage/index.html index cd530b82b4fc7a9..34b7c40bf494fa3 100644 --- a/files/en-us/web/api/storageestimate/usage/index.html +++ b/files/en-us/web/api/storageestimate/usage/index.html @@ -21,7 +21,7 @@Syntax
-usage = StorageEstimate.usage; +usage = StorageEstimate.usage;Value
diff --git a/files/en-us/web/api/storageevent/index.html b/files/en-us/web/api/storageevent/index.html index 4ded33031c062df..8cff93e162b8a5f 100644 --- a/files/en-us/web/api/storageevent/index.html +++ b/files/en-us/web/api/storageevent/index.html @@ -17,7 +17,7 @@Method overview
-void initStorageEvent( +void initStorageEvent( in DOMString type, in boolean canBubble, in boolean cancelable, @@ -84,7 +84,7 @@initStorageEvent()
Syntax
-storageEvent.initStorageEvent(type[, canBubble[, cancelable[, key[, oldValue[, newValue[, url[, storageArea]]]]]]]) +storageEvent.initStorageEvent(type[, canBubble[, cancelable[, key[, oldValue[, newValue[, url[, storageArea]]]]]]])Parameters
diff --git a/files/en-us/web/api/stylepropertymapreadonly/entries/index.html b/files/en-us/web/api/stylepropertymapreadonly/entries/index.html index 31c0536760ba6be..e5abe3abf7e0986 100644 --- a/files/en-us/web/api/stylepropertymapreadonly/entries/index.html +++ b/files/en-us/web/api/stylepropertymapreadonly/entries/index.html @@ -21,7 +21,7 @@Syntax
-StylePropertyMapReadOnly.entries()+StylePropertyMapReadOnly.entries()Parameters
@@ -37,7 +37,7 @@Example
Here shows an example of using
-StylePropertyMapReadOnly.entries()
method on an elements computed styles.// grab a dom element +// grab a dom element const buttonEl = document.querySelector('button'); // we can retrieve all computed styles with `computedStyleMap` diff --git a/files/en-us/web/api/stylepropertymapreadonly/foreach/index.html b/files/en-us/web/api/stylepropertymapreadonly/foreach/index.html index ac4e662c9de1c7b..ab46edd7e580a52 100644 --- a/files/en-us/web/api/stylepropertymapreadonly/foreach/index.html +++ b/files/en-us/web/api/stylepropertymapreadonly/foreach/index.html @@ -18,7 +18,7 @@Syntax
-StylePropertyMapReadOnly.forEach(function callback(currentValue[, index[, array]]) { +StylePropertyMapReadOnly.forEach(function callback(currentValue[, index[, array]]) { //your code }[, thisArg]);@@ -52,7 +52,7 @@Example
Here is an example of using
-forEach()
on a retrieved {{domxref('Element.computedStyleMap()')}}.// get a button element +// get a button element const buttonEl = document.querySelector('.example'); // we can retrieve all computed styles with `computedStyleMap` diff --git a/files/en-us/web/api/stylepropertymapreadonly/get/index.html b/files/en-us/web/api/stylepropertymapreadonly/get/index.html index 92e36e05abed101..1f3fe012775b3aa 100644 --- a/files/en-us/web/api/stylepropertymapreadonly/get/index.html +++ b/files/en-us/web/api/stylepropertymapreadonly/get/index.html @@ -19,7 +19,7 @@Syntax
var declarationBlock = StylePropertyMapReadOnly.get(property)+ class="brush: js">var declarationBlock = StylePropertyMapReadOnly.get(property)Parameters
@@ -38,14 +38,14 @@Examples
paragraph in our HTML, and adding a definition list which we will populate with JavaScript: -<p> +<p> <a href="https://example.com">Link</a> </p> <dl id="results"></dl>We add a bit of CSS, including a custom property and an inheritable property:
-p { +p { font-weight: bold; } a { @@ -59,7 +59,7 @@Examples
of interest and use the StylePropertyMapReadOnly'sget()
method to get only those values. -// get the element +// get the element const myElement = document.querySelector('a'); // Retrieve all computed styles with computedStyleMap() diff --git a/files/en-us/web/api/stylepropertymapreadonly/getall/index.html b/files/en-us/web/api/stylepropertymapreadonly/getall/index.html index c632555f211cf8a..2ca30ade235eb7b 100644 --- a/files/en-us/web/api/stylepropertymapreadonly/getall/index.html +++ b/files/en-us/web/api/stylepropertymapreadonly/getall/index.html @@ -21,7 +21,7 @@Syntax
var cssStyleValues[] = StylePropertyMapReadOnly.getAll(property)+ class="brush: js">var cssStyleValues[] = StylePropertyMapReadOnly.getAll(property)Parameters
@@ -40,7 +40,7 @@Example
{{cssxref('background-image')}} property. An {{jsxref('Array')}} is returned which contains an item for each background image declared. -// get a button element +// get a button element const buttonEl = document.querySelector('button'); // we can retrieve all computed styles with `computedStyleMap` diff --git a/files/en-us/web/api/stylepropertymapreadonly/has/index.html b/files/en-us/web/api/stylepropertymapreadonly/has/index.html index 81b20e2f3b4cb07..bc568b439b3c964 100644 --- a/files/en-us/web/api/stylepropertymapreadonly/has/index.html +++ b/files/en-us/web/api/stylepropertymapreadonly/has/index.html @@ -20,7 +20,7 @@Syntax
var boolean = StylePropertyMapReadOnly.has(property)+ class="brush: js">var boolean = StylePropertyMapReadOnly.has(property)Parameters
@@ -38,7 +38,7 @@Example
Here we use the
-has()
method to see if the padding-top property is present within the button elements style attribute.// get the button element +// get the button element const buttonEl = document.querySelector('.example'); // find what's in the style attribute with attributeStyleMap and has() diff --git a/files/en-us/web/api/stylepropertymapreadonly/index.html b/files/en-us/web/api/stylepropertymapreadonly/index.html index 656b1e1b646412b..5db432063190213 100644 --- a/files/en-us/web/api/stylepropertymapreadonly/index.html +++ b/files/en-us/web/api/stylepropertymapreadonly/index.html @@ -44,7 +44,7 @@Examples
We have to have an element to observe:
-<p> +<p> This is a paragraph with some text. We can add some CSS, or not. The style map will include all the default and inherted CSS property values. </p> @@ -52,7 +52,7 @@Examples
We add a touch of CSS with a custom property to better demonstrate the output:
-p { +p { --someVariable: 1.6em; --someOtherVariable: translateX(33vw); --anotherVariable: 42; @@ -61,7 +61,7 @@Examples
We add JavaScript to grab our paragraph and return back a definition list of all the default CSS property values using {{domxref('Element.computedStyleMap()')}}.
-// get the element +// get the element const myElement = document.querySelector('p'); // get the <dl> we'll be populating diff --git a/files/en-us/web/api/stylepropertymapreadonly/keys/index.html b/files/en-us/web/api/stylepropertymapreadonly/keys/index.html index e89e239af835b24..237301dff1ebe59 100644 --- a/files/en-us/web/api/stylepropertymapreadonly/keys/index.html +++ b/files/en-us/web/api/stylepropertymapreadonly/keys/index.html @@ -19,7 +19,7 @@Syntax
-StylePropertyMapReadOnly.keys()+StylePropertyMapReadOnly.keys()Parameters
@@ -34,7 +34,7 @@Example
In this example we use the
-keys()
method to be able to access the properties within our {{domxref('Element.computedStyleMap()')}}.// get a button element +// get a button element const buttonEl = document.querySelector('button'); // we can retrieve all computed styles with `computedStyleMap` diff --git a/files/en-us/web/api/stylepropertymapreadonly/size/index.html b/files/en-us/web/api/stylepropertymapreadonly/size/index.html index 3744140b2088178..378e5216a3f2990 100644 --- a/files/en-us/web/api/stylepropertymapreadonly/size/index.html +++ b/files/en-us/web/api/stylepropertymapreadonly/size/index.html @@ -20,7 +20,7 @@Syntax
var size = StylePropertyMapReadOnly.size+ class="brush: js">var size = StylePropertyMapReadOnly.sizeValue
@@ -31,7 +31,7 @@Example
Here we use the size property to return the total entries within the button elements {{domxref('Element.computedStyleMap()','computedStyleMap')}}.
-// grab our element +// grab our element const buttonEl = document.querySelector('button'); // we can retrieve all computed styles with `computedStyleMap` diff --git a/files/en-us/web/api/stylepropertymapreadonly/values/index.html b/files/en-us/web/api/stylepropertymapreadonly/values/index.html index 3961504447fbbee..ed34b282385dffd 100644 --- a/files/en-us/web/api/stylepropertymapreadonly/values/index.html +++ b/files/en-us/web/api/stylepropertymapreadonly/values/index.html @@ -19,7 +19,7 @@Syntax
-StylePropertyMapReadOnly.values()+StylePropertyMapReadOnly.values()Parameters
@@ -36,7 +36,7 @@Example
href="/en-US/docs/Web/API/Element/computedStyleMap">Element.computedStyleMap()
. -// get a button element +// get a button element const buttonEl = document.querySelector('button'); // we can retrieve all computed styles with `computedStyleMap` diff --git a/files/en-us/web/api/wheelevent/deltamode/index.html b/files/en-us/web/api/wheelevent/deltamode/index.html index dcb99f5284cceac..a02363ed638979c 100644 --- a/files/en-us/web/api/wheelevent/deltamode/index.html +++ b/files/en-us/web/api/wheelevent/deltamode/index.html @@ -43,7 +43,7 @@Syntax
var+ class="brush: js">varunit = event.deltaMode;
unit = event.deltaMode;
Example
diff --git a/files/en-us/web/api/wheelevent/deltax/index.html b/files/en-us/web/api/wheelevent/deltax/index.html index 37ef4c5b6019637..4bb3c8696856959 100644 --- a/files/en-us/web/api/wheelevent/deltax/index.html +++ b/files/en-us/web/api/wheelevent/deltax/index.html @@ -19,7 +19,7 @@Syntax
var+ class="brush: js">vardX = event.deltaX;
dX = event.deltaX;
Example
diff --git a/files/en-us/web/api/wheelevent/deltay/index.html b/files/en-us/web/api/wheelevent/deltay/index.html index 62d88ffdddeee93..1fa146779a90259 100644 --- a/files/en-us/web/api/wheelevent/deltay/index.html +++ b/files/en-us/web/api/wheelevent/deltay/index.html @@ -19,7 +19,7 @@Syntax
var+ class="brush: js">vardY = event.deltaY;
dY = event.deltaY;
Example
diff --git a/files/en-us/web/api/wheelevent/deltaz/index.html b/files/en-us/web/api/wheelevent/deltaz/index.html index 9eda9692188fdae..59d1347a6db3e4f 100644 --- a/files/en-us/web/api/wheelevent/deltaz/index.html +++ b/files/en-us/web/api/wheelevent/deltaz/index.html @@ -20,11 +20,11 @@Syntax
var+ class="brush: js">vardZ = event.deltaZ;
dZ = event.deltaZ;
Example
-var syntheticEvent = new WheelEvent("syntheticWheel", {"deltaZ": 4, "deltaMode": 0}); +var syntheticEvent = new WheelEvent("syntheticWheel", {"deltaZ": 4, "deltaMode": 0}); console.log(syntheticEvent.deltaZ);diff --git a/files/en-us/web/api/wheelevent/wheelevent/index.html b/files/en-us/web/api/wheelevent/wheelevent/index.html index e9ce00bf0622d38..4afac4611b2c576 100644 --- a/files/en-us/web/api/wheelevent/wheelevent/index.html +++ b/files/en-us/web/api/wheelevent/wheelevent/index.html @@ -15,7 +15,7 @@Syntax
-var wheelEvent = new WheelEvent(typeArg, wheelEventInit); +var wheelEvent = new WheelEvent(typeArg, wheelEventInit);Properties
diff --git a/files/en-us/web/api/xrpose/emulatedposition/index.html b/files/en-us/web/api/xrpose/emulatedposition/index.html index 4be7e35dd6f3e84..d82db4daa73ccbc 100644 --- a/files/en-us/web/api/xrpose/emulatedposition/index.html +++ b/files/en-us/web/api/xrpose/emulatedposition/index.html @@ -35,7 +35,7 @@Syntax
let emulated = xrPose.emulatedPosition;+ class="brush: js">let emulated = xrPose.emulatedPosition;Value
diff --git a/files/en-us/web/api/xrpose/transform/index.html b/files/en-us/web/api/xrpose/transform/index.html index 71c3a19f1cc58ea..2f058d8510a7c6c 100644 --- a/files/en-us/web/api/xrpose/transform/index.html +++ b/files/en-us/web/api/xrpose/transform/index.html @@ -28,7 +28,7 @@Syntax
let poseTransform = xrPose.transform;+ class="brush: js">let poseTransform = xrPose.transform;Value
diff --git a/files/en-us/web/api/xrreferencespace/getoffsetreferencespace/index.html b/files/en-us/web/api/xrreferencespace/getoffsetreferencespace/index.html index 40a2f3691ac272a..0c76a343af5daa3 100644 --- a/files/en-us/web/api/xrreferencespace/getoffsetreferencespace/index.html +++ b/files/en-us/web/api/xrreferencespace/getoffsetreferencespace/index.html @@ -48,7 +48,7 @@Syntax
offsetReferenceSpace = xrReferenceSpace.getOffsetReferenceSpace(originOffset);+ class="brush: js">offsetReferenceSpace = xrReferenceSpace.getOffsetReferenceSpace(originOffset);Parameters
@@ -83,7 +83,7 @@Teleporting or settin
Upon first creating a scene, you may need to set the user's position within the 3D world. You can do that using
-getOffsetReferenceSpace()
.xrSession.requestReferenceSpace("local") +xrSession.requestReferenceSpace("local") .then((refSpace) => { xrReferenceSpace = refSpace; xrReferenceSpace = xrReferenceSpace.getOffsetReferenceSpace( @@ -117,7 +117,7 @@Implementing rotation base events. This prevents the right-clicks from causing the context menu from appearing in the browser. -
canvas.oncontextmenu = (event) => { event.preventDefault(); }; +canvas.oncontextmenu = (event) => { event.preventDefault(); }; canvas.addEventListener("mousemove", (event) => { if (event.buttons & 2) { rotateViewBy(event.movementX, event.movementY); @@ -131,7 +131,7 @@Implementing rotation base straight up and straight down. Each time this is called, the new offsets are used to update the current values of
mousePitch
andmouseYaw
. -let mouseYaw = 0.0; +let mouseYaw = 0.0; let mousePitch = 0.0; const inverseOrientation = quat.create(); const MOUSE_SPEED = 0.003; @@ -150,7 +150,7 @@Implementing rotation base
Finally, we need code that actually applies the computed yaw and pitch to the viewer's orientation. This function,
-applyMouseMovement()
, handles that:function applyMouseMovement(refSpace) { +function applyMouseMovement(refSpace) { if (!mouseYaw && !mousePitch) { return refSpace; } diff --git a/files/en-us/web/api/xrreferencespace/onreset/index.html b/files/en-us/web/api/xrreferencespace/onreset/index.html index a86cb548ca9c628..2e6709462a0828e 100644 --- a/files/en-us/web/api/xrreferencespace/onreset/index.html +++ b/files/en-us/web/api/xrreferencespace/onreset/index.html @@ -32,7 +32,7 @@Syntax
-xrReferenceSpace.onreset = eventHandler; +xrReferenceSpace.onreset = eventHandler; eventHandler = xrReferenceSpace.onreset;diff --git a/files/en-us/web/api/xrreferencespace/reset_event/index.html b/files/en-us/web/api/xrreferencespace/reset_event/index.html index 90e7c0deeda5bf8..0c29784f4721ef2 100644 --- a/files/en-us/web/api/xrreferencespace/reset_event/index.html +++ b/files/en-us/web/api/xrreferencespace/reset_event/index.html @@ -83,14 +83,14 @@Examples
To add a handler for the
-reset
event, you can use either of two approaches. First, you can use the {{domxref("EventTarget.addEventListener", "addEventListener()")}} method:viewerRefSpace.addEventListener("reset", (event) => { +viewerRefSpace.addEventListener("reset", (event) => { /* perform reset related tasks */ });The second option is to set the
-XRReferenceSpace
object's {{domxref("XRReferenceSpace.onreset", "onreset")}} event handler property:viewerRefSpace.onreset = (event) => { +viewerRefSpace.onreset = (event) => { /* perform reset related tasks */ };diff --git a/files/en-us/web/api/xrsession/cancelanimationframe/index.html b/files/en-us/web/api/xrsession/cancelanimationframe/index.html index 620a04f0fd4136c..f50a4c97fe91287 100644 --- a/files/en-us/web/api/xrsession/cancelanimationframe/index.html +++ b/files/en-us/web/api/xrsession/cancelanimationframe/index.html @@ -25,7 +25,7 @@Syntax
-xrSession.cancelAnimationFrame(handle); +xrSession.cancelAnimationFrame(handle);Parameters
diff --git a/files/en-us/web/api/xrsession/end/index.html b/files/en-us/web/api/xrsession/end/index.html index 1c4e4a10c8c2daa..43f6f6d0a7ed833 100644 --- a/files/en-us/web/api/xrsession/end/index.html +++ b/files/en-us/web/api/xrsession/end/index.html @@ -23,7 +23,7 @@Syntax
-xrSession.end(); +xrSession.end();Parameters
diff --git a/files/en-us/web/api/xrsession/environmentblendmode/index.html b/files/en-us/web/api/xrsession/environmentblendmode/index.html index 97a69882a4f526e..30b8a0af4d17d82 100644 --- a/files/en-us/web/api/xrsession/environmentblendmode/index.html +++ b/files/en-us/web/api/xrsession/environmentblendmode/index.html @@ -38,7 +38,7 @@Syntax
blendMode = xrSession.environmentBlendMode;+ class="brush: js">blendMode = xrSession.environmentBlendMode;Value
diff --git a/files/en-us/web/api/xrsession/inputsources/index.html b/files/en-us/web/api/xrsession/inputsources/index.html index 5bc60b42d2a783f..829359e95481ede 100644 --- a/files/en-us/web/api/xrsession/inputsources/index.html +++ b/files/en-us/web/api/xrsession/inputsources/index.html @@ -33,7 +33,7 @@Syntax
inputSources = xrSession.inputSources;+ class="brush: js">inputSources = xrSession.inputSources;Value
diff --git a/files/en-us/web/api/xrsession/onend/index.html b/files/en-us/web/api/xrsession/onend/index.html index ab945dbd2edbaa9..41c219cf5c2b2f2 100644 --- a/files/en-us/web/api/xrsession/onend/index.html +++ b/files/en-us/web/api/xrsession/onend/index.html @@ -24,7 +24,7 @@Syntax
-XRSession.onend = function(event) { ... }; +XRSession.onend = function(event) { ... };Example
diff --git a/files/en-us/web/api/xrsession/onselect/index.html b/files/en-us/web/api/xrsession/onselect/index.html index 33d5d195d384f23..d1b855ca11d482b 100644 --- a/files/en-us/web/api/xrsession/onselect/index.html +++ b/files/en-us/web/api/xrsession/onselect/index.html @@ -36,7 +36,7 @@Syntax
-xrSession.onselect = selectHandlerFunction; +xrSession.onselect = selectHandlerFunction;Value
diff --git a/files/en-us/web/api/xrsession/onselectend/index.html b/files/en-us/web/api/xrsession/onselectend/index.html index 978f46aaf73088f..8459f8d72400aba 100644 --- a/files/en-us/web/api/xrsession/onselectend/index.html +++ b/files/en-us/web/api/xrsession/onselectend/index.html @@ -29,7 +29,7 @@Syntax
-XRSession.onselectend = function(event) { ... } +XRSession.onselectend = function(event) { ... }Example
diff --git a/files/en-us/web/api/xrsession/onselectstart/index.html b/files/en-us/web/api/xrsession/onselectstart/index.html index 0562f61d42ab607..eea67bb7e88b4ec 100644 --- a/files/en-us/web/api/xrsession/onselectstart/index.html +++ b/files/en-us/web/api/xrsession/onselectstart/index.html @@ -31,7 +31,7 @@Syntax
-XRSession.onselectstart = function(event) { ... } +XRSession.onselectstart = function(event) { ... }Example
diff --git a/files/en-us/web/api/xrsession/onsqueeze/index.html b/files/en-us/web/api/xrsession/onsqueeze/index.html index 4eb4a61837b0d90..b0e7ef6f2da131c 100644 --- a/files/en-us/web/api/xrsession/onsqueeze/index.html +++ b/files/en-us/web/api/xrsession/onsqueeze/index.html @@ -36,7 +36,7 @@Syntax
xrSession.onsqueeze = squeezeHandlerFunction;+ class="brush: js">xrSession.onsqueeze = squeezeHandlerFunction;Value
diff --git a/files/en-us/web/api/xrsession/onsqueezeend/index.html b/files/en-us/web/api/xrsession/onsqueezeend/index.html index 8361c2f4c4966a4..1a29bbf9c15a809 100644 --- a/files/en-us/web/api/xrsession/onsqueezeend/index.html +++ b/files/en-us/web/api/xrsession/onsqueezeend/index.html @@ -40,7 +40,7 @@Syntax
xrSession.onsqueezeend = squeezeendHandlerFunction;+ class="brush: js">xrSession.onsqueezeend = squeezeendHandlerFunction;Value
diff --git a/files/en-us/web/api/xrsession/onsqueezestart/index.html b/files/en-us/web/api/xrsession/onsqueezestart/index.html index 6cda77d99d7dd62..ab8837d94d50e13 100644 --- a/files/en-us/web/api/xrsession/onsqueezestart/index.html +++ b/files/en-us/web/api/xrsession/onsqueezestart/index.html @@ -37,7 +37,7 @@Syntax
xrSession.onsqueezestart = squeezestartHandlerFunction;+ class="brush: js">xrSession.onsqueezestart = squeezestartHandlerFunction;Value
diff --git a/files/en-us/web/api/xrsession/onvisibilitychange/index.html b/files/en-us/web/api/xrsession/onvisibilitychange/index.html index 31e014e10478f2a..eb2aa985f81939f 100644 --- a/files/en-us/web/api/xrsession/onvisibilitychange/index.html +++ b/files/en-us/web/api/xrsession/onvisibilitychange/index.html @@ -29,7 +29,7 @@Syntax
-XRSession.onvisibilitychange = function(event) { ... } +XRSession.onvisibilitychange = function(event) { ... }Example
diff --git a/files/en-us/web/api/xrsession/renderstate/index.html b/files/en-us/web/api/xrsession/renderstate/index.html index e1690a1a134dc89..a7a490ff5a28663 100644 --- a/files/en-us/web/api/xrsession/renderstate/index.html +++ b/files/en-us/web/api/xrsession/renderstate/index.html @@ -31,7 +31,7 @@Syntax
var xrRenderState = XRSession.renderState;+ class="brush: js">var xrRenderState = XRSession.renderState;Value
diff --git a/files/en-us/web/api/xrsession/requestanimationframe/index.html b/files/en-us/web/api/xrsession/requestanimationframe/index.html index dd46614db213888..e77aa61c2e41db9 100644 --- a/files/en-us/web/api/xrsession/requestanimationframe/index.html +++ b/files/en-us/web/api/xrsession/requestanimationframe/index.html @@ -43,7 +43,7 @@Syntax
-requestID = xrSession.requestAnimationFrame(animationFrameCallback); +requestID = xrSession.requestAnimationFrame(animationFrameCallback);Parameters
diff --git a/files/en-us/web/api/xrsession/requestreferencespace/index.html b/files/en-us/web/api/xrsession/requestreferencespace/index.html index 039bb51ddede9e6..4b8a62fac5ba181 100644 --- a/files/en-us/web/api/xrsession/requestreferencespace/index.html +++ b/files/en-us/web/api/xrsession/requestreferencespace/index.html @@ -30,7 +30,7 @@Syntax
refSpacePromise = xrSession.requestReferenceSpace(referenceSpaceType);+ class="brush: js">refSpacePromise = xrSession.requestReferenceSpace(referenceSpaceType);Parameters
diff --git a/files/en-us/web/api/xrsession/updaterenderstate/index.html b/files/en-us/web/api/xrsession/updaterenderstate/index.html index 876ed3ce02add0f..ed65db83d93c01a 100644 --- a/files/en-us/web/api/xrsession/updaterenderstate/index.html +++ b/files/en-us/web/api/xrsession/updaterenderstate/index.html @@ -29,7 +29,7 @@Syntax
xrSession.updateRenderState(newState)+ class="brush: js">xrSession.updateRenderState(newState)Parameters
diff --git a/files/en-us/web/api/xrsession/visibilitystate/index.html b/files/en-us/web/api/xrsession/visibilitystate/index.html index a5652ef1e2e9bdb..079e4b461670967 100644 --- a/files/en-us/web/api/xrsession/visibilitystate/index.html +++ b/files/en-us/web/api/xrsession/visibilitystate/index.html @@ -30,7 +30,7 @@Syntax
visibilityState = xrSession.visibilityState;+ class="brush: js">visibilityState = xrSession.visibilityState;Value
diff --git a/files/en-us/web/javascript/a_re-introduction_to_javascript/index.html b/files/en-us/web/javascript/a_re-introduction_to_javascript/index.html index 1bea7e37dc9b892..88ab003742858d9 100644 --- a/files/en-us/web/javascript/a_re-introduction_to_javascript/index.html +++ b/files/en-us/web/javascript/a_re-introduction_to_javascript/index.html @@ -63,33 +63,33 @@Numbers
Numbers in JavaScript are "double-precision 64-bit format IEEE 754 values", according to the spec — There's no such thing as an integer in JavaScript (except {{jsxref("BigInt")}}), so you have to be a little careful. See this example:
-console.log(3 / 2); // 1.5, not 1 +console.log(3 / 2); // 1.5, not 1 console.log(Math.floor(3 / 2)); // 1So an apparent integer is in fact implicitly a float.
Also, watch out for stuff like:
-0.1 + 0.2 == 0.30000000000000004; +0.1 + 0.2 == 0.30000000000000004;In practice, integer values are treated as 32-bit ints, and some implementations even store it that way until they are asked to perform an instruction that's valid on a Number but not on a 32-bit integer. This can be important for bit-wise operations.
The standard arithmetic operators are supported, including addition, subtraction, modulus (or remainder) arithmetic, and so forth. There's also a built-in object that we did not mention earlier called {{jsxref("Math")}} that provides advanced mathematical functions and constants:
-Math.sin(3.5); +Math.sin(3.5); var circumference = 2 * Math.PI * r;You can convert a string to an integer using the built-in {{jsxref("Global_Objects/parseInt", "parseInt()")}} function. This takes the base for the conversion as an optional second argument, which you should always provide:
-parseInt('123', 10); // 123 +parseInt('123', 10); // 123 parseInt('010', 10); // 10In older browsers, strings beginning with a "0" are assumed to be in octal (radix 8), but this hasn't been the case since 2013 or so. Unless you're certain of your string format, you can get surprising results on those older browsers:
-parseInt('010'); // 8 +parseInt('010'); // 8 parseInt('0x10'); // 16@@ -97,42 +97,42 @@Numbers
If you want to convert a binary number to an integer, just change the base:
-parseInt('11', 2); // 3 +parseInt('11', 2); // 3Similarly, you can parse floating point numbers using the built-in {{jsxref("Global_Objects/parseFloat", "parseFloat()")}} function. Unlike its {{jsxref("Global_Objects/parseInt", "parseInt()")}} cousin,
parseFloat()
always uses base 10.You can also use the unary
-+
operator to convert values to numbers:+ '42'; // 42 ++ '42'; // 42 + '010'; // 10 + '0x10'; // 16A special value called {{jsxref("NaN")}} (short for "Not a Number") is returned if the string is non-numeric:
-parseInt('hello', 10); // NaN +parseInt('hello', 10); // NaN-
NaN
is toxic: if you provide it as an operand to any mathematical operation, the result will also beNaN
:NaN + 5; // NaN +NaN + 5; // NaNYou can test for
-NaN
using the built-in {{jsxref("Global_Objects/isNaN", "isNaN()")}} function:isNaN(NaN); // true +isNaN(NaN); // trueJavaScript also has the special values {{jsxref("Infinity")}} and
--Infinity
:1 / 0; // Infinity +1 / 0; // Infinity -1 / 0; // -InfinityYou can test for
-Infinity
,-Infinity
andNaN
values using the built-in {{jsxref("Global_Objects/isFinite", "isFinite()")}} function:isFinite(1 / 0); // false +isFinite(1 / 0); // false isFinite(-Infinity); // false isFinite(NaN); // false@@ -147,12 +147,12 @@Strings
To find the length of a string (in code units), access its
-length
property:'hello'.length; // 5 +'hello'.length; // 5There's our first brush with JavaScript objects! Did we mention that you can use strings like {{jsxref("Object", "objects", "", 1)}} too? They have {{jsxref("String", "methods", "#Methods", 1)}} as well that allow you to manipulate the string and access information about the string:
-'hello'.charAt(0); // "h" +'hello'.charAt(0); // "h" 'hello, world'.replace('world', 'mars'); // "hello, mars" 'hello'.toUpperCase(); // "HELLO"@@ -170,7 +170,7 @@Other types
You can perform this conversion explicitly using the
-Boolean()
function:Boolean(''); // false +Boolean(''); // false Boolean(234); // true@@ -184,13 +184,13 @@Variables
let
allows you to declare block-level variables. The declared variable is available from the block it is enclosed in. -let a; +let a; let name = 'Simon';The following is an example of scope with a variable declared with
-let
:// myLetVariable is *not* visible out here +// myLetVariable is *not* visible out here for (let myLetVariable = 0; myLetVariable < 5; myLetVariable++) { // myLetVariable is only visible in here @@ -202,18 +202,18 @@Variables
-
const
allows you to declare variables whose values are never intended to change. The variable is available from the block it is declared in.const Pi = 3.14; // variable Pi is set +const Pi = 3.14; // variable Pi is set Pi = 1; // will throw an error because you cannot change a constant variable.-
var
is the most common declarative keyword. It does not have the restrictions that the other two keywords have. This is because it was traditionally the only way to declare a variable in JavaScript. A variable declared with thevar
keyword is available from the function it is declared in.var a; +var a; var name = 'Simon';An example of scope with a variable declared with
-var
:// myVarVariable *is* visible out here +// myVarVariable *is* visible out here for (var myVarVariable = 0; myVarVariable < 5; myVarVariable++) { // myVarVariable is visible to the whole function @@ -230,7 +230,7 @@Operators
JavaScript's numeric operators are
-+
,-
,*
,/
and%
which is the remainder operator (which is the same as modulo.) Values are assigned using=
, and there are also compound assignment statements such as+=
and-=
. These extend out tox = x operator y
.x += 5; +x += 5; x = x + 5;@@ -238,12 +238,12 @@Operators
The
-+
operator also does string concatenation:'hello' + ' world'; // "hello world" +'hello' + ' world'; // "hello world"If you add a string to a number (or other value) everything is converted into a string first. This might trip you up:
-'3' + 4 + 5; // "345" +'3' + 4 + 5; // "345" 3 + 4 + '5'; // "75"@@ -251,13 +251,13 @@Operators
Comparisons in JavaScript can be made using
-<
,>
,<=
and>=
. These work for both strings and numbers. Equality is a little less straightforward. The double-equals operator performs type coercion if you give it different types, with sometimes interesting results:123 == '123'; // true +123 == '123'; // true 1 == true; // trueTo avoid type coercion, use the triple-equals operator:
-123 === '123'; // false +123 === '123'; // false 1 === true; // false@@ -269,7 +269,7 @@Control structures
JavaScript has a similar set of control structures to other languages in the C family. Conditional statements are supported by
-if
andelse
; you can chain them together if you like:var name = 'kittens'; +var name = 'kittens'; if (name == 'puppies') { name += ' woof'; } else if (name == 'kittens') { @@ -282,7 +282,7 @@Control structures
JavaScript has
-while
loops anddo-while
loops. The first is good for basic looping; the second for loops where you wish to ensure that the body of the loop is executed at least once:while (true) { +while (true) { // an infinite loop! } @@ -294,43 +294,43 @@Control structures
JavaScript's
-for
loop is the same as that in C and Java: it lets you provide the control information for your loop on a single line.for (var i = 0; i < 5; i++) { +for (var i = 0; i < 5; i++) { // Will execute 5 times }JavaScript also contains two other prominent for loops:
-for
...of
for (let value of array) { +for (let value of array) { // do something with value }and
-for
...in
:for (let property in object) { +for (let property in object) { // do something with object property }The
-&&
and||
operators use short-circuit logic, which means whether they will execute their second operand is dependent on the first. This is useful for checking for null objects before accessing their attributes:var name = o && o.getName(); +var name = o && o.getName();Or for caching values (when falsy values are invalid):
-var name = cachedName || (cachedName = getName()); +var name = cachedName || (cachedName = getName());JavaScript has a ternary operator for conditional expressions:
-var allowed = (age > 18) ? 'yes' : 'no'; +var allowed = (age > 18) ? 'yes' : 'no';The
-switch
statement can be used for multiple branches based on a number or string:switch (action) { +switch (action) { case 'draw': drawIt(); break; @@ -344,7 +344,7 @@Control structures
If you don't add a
-break
statement, execution will "fall through" to the next level. This is very rarely what you want — in fact it's worth specifically labeling deliberate fallthrough with a comment if you really meant it to aid debugging:switch (a) { +switch (a) { case 1: // fallthrough case 2: eatIt(); @@ -356,7 +356,7 @@Control structures
The default clause is optional. You can have expressions in both the switch part and the cases if you like; comparisons take place between the two using the
-===
operator:switch (1 + 3) { +switch (1 + 3) { case 2 + 2: yay(); break; @@ -383,19 +383,19 @@Objects
There are two basic ways to create an empty object:
-var obj = new Object(); +var obj = new Object();And:
-var obj = {}; +var obj = {};These are semantically equivalent; the second is called object literal syntax and is more convenient. This syntax is also the core of JSON format and should be preferred at all times.
Object literal syntax can be used to initialize an object in its entirety:
-var obj = { +var obj = { name: 'Carrot', _for: 'Max', // 'for' is a reserved word, use '_for' instead. details: { @@ -407,13 +407,13 @@Objects
Attribute access can be chained together:
-obj.details.color; // orange +obj.details.color; // orange obj['details']['size']; // 12The following example creates an object prototype(
-Person
) and an instance of that prototype(you
).function Person(name, age) { +function Person(name, age) { this.name = name; this.age = age; } @@ -426,14 +426,14 @@Objects
Once created, an object's properties can again be accessed in one of two ways:
-// dot notation +// dot notation obj.name = 'Simon'; var name = obj.name;And...
-// bracket notation +// bracket notation obj['name'] = 'Simon'; var name = obj['name']; // can use a variable to define a key @@ -443,7 +443,7 @@Objects
These are also semantically equivalent. The second method has the advantage that the name of the property is provided as a string, which means it can be calculated at run-time. However, using this method prevents some JavaScript engine and minifier optimizations being applied. It can also be used to set and get properties with names that are reserved words:
-obj.for = 'Simon'; // Syntax error, because 'for' is a reserved word +obj.for = 'Simon'; // Syntax error, because 'for' is a reserved word obj['for'] = 'Simon'; // works fine@@ -463,7 +463,7 @@Arrays
One way of creating arrays is as follows:
-var a = new Array(); +var a = new Array(); a[0] = 'dog'; a[1] = 'cat'; a[2] = 'hen'; @@ -472,13 +472,13 @@Arrays
A more convenient notation is to use an array literal:
-var a = ['dog', 'cat', 'hen']; +var a = ['dog', 'cat', 'hen']; a.length; // 3Note that
-array.length
isn't necessarily the number of items in the array. Consider the following:var a = ['dog', 'cat', 'hen']; +var a = ['dog', 'cat', 'hen']; a[100] = 'fox'; a.length; // 101@@ -487,19 +487,19 @@Arrays
If you query a non-existent array index, you'll get a value of
-undefined
in return:typeof a[90]; // undefined +typeof a[90]; // undefinedIf you take the above about
-[]
andlength
into account, you can iterate over an array using the followingfor
loop:for (var i = 0; i < a.length; i++) { +for (var i = 0; i < a.length; i++) { // Do something with a[i] }ES2015 introduced the more concise
-for
...of
loop for iterable objects such as arrays:for (const currentValue of a) { +for (const currentValue of a) { // Do something with currentValue }@@ -507,14 +507,14 @@Arrays
Another way of iterating over an array that was added with ECMAScript 5 is
-forEach()
:['dog', 'cat', 'hen'].forEach(function(currentValue, index, array) { +['dog', 'cat', 'hen'].forEach(function(currentValue, index, array) { // Do something with currentValue or array[index] });If you want to append an item to an array do it like this:
-a.push(item);+a.push(item);Arrays come with a number of methods. See also the full documentation for array methods.
@@ -581,7 +581,7 @@Functions
Along with objects, functions are the core component in understanding JavaScript. The most basic function couldn't be much simpler:
-function add(x, y) { +function add(x, y) { var total = x + y; return total; } @@ -591,19 +591,19 @@Functions
The named parameters turn out to be more like guidelines than anything else. You can call a function without passing the parameters it expects, in which case they will be set to
-undefined
.add(); // NaN +add(); // NaN // You can't perform addition on undefinedYou can also pass in more arguments than the function is expecting:
-add(2, 3, 4); // 5 +add(2, 3, 4); // 5 // added the first two; 4 was ignoredThat may seem a little silly, but functions have access to an additional variable inside their body called
-arguments
, which is an array-like object holding all of the values passed to the function. Let's re-write the add function to take as many values as we want:function add() { +function add() { var sum = 0; for (var i = 0, j = arguments.length; i < j; i++) { sum += arguments[i]; @@ -616,7 +616,7 @@Functions
That's really not any more useful than writing
-2 + 3 + 4 + 5
though. Let's create an averaging function:function avg() { +function avg() { var sum = 0; for (var i = 0, j = arguments.length; i < j; i++) { sum += arguments[i]; @@ -629,7 +629,7 @@Functions
This is pretty useful, but it does seem a little verbose. To reduce this code a bit more we can look at substituting the use of the arguments array through Rest parameter syntax. In this way, we can pass in any number of arguments into the function while keeping our code minimal. The rest parameter operator is used in function parameter lists with the format: ...variable and it will include within that variable the entire list of uncaptured arguments that the function was called with. We will also replace the for loop with a for...of loop to return the values within our variable.
-function avg(...args) { +function avg(...args) { var sum = 0; for (let value of args) { sum += value; @@ -644,7 +644,7 @@Functions
It is important to note that wherever the rest parameter operator is placed in a function declaration it will store all arguments after its declaration, but not before. i.e. function avg(firstValue, ...args) will store the first value passed into the function in the firstValue variable and the remaining arguments in args. That's another useful language feature but it does lead us to a new problem. Theavg()
function takes a comma-separated list of arguments — but what if you want to find the average of an array? You could just rewrite the function as follows:function avgArray(arr) { +function avgArray(arr) { var sum = 0; for (var i = 0, j = arr.length; i < j; i++) { sum += arr[i]; @@ -657,7 +657,7 @@Functions
But it would be nice to be able to reuse the function that we've already created. Luckily, JavaScript lets you call a function with an arbitrary array of arguments, using the {{jsxref("Function.apply", "apply()")}} method of any function object.
-avg.apply(null, [2, 3, 4, 5]); // 3.5 +avg.apply(null, [2, 3, 4, 5]); // 3.5The second argument to
@@ -670,7 +670,7 @@apply()
is the array to use as arguments; the first will be discussed later on. This emphasizes the fact that functions are objects too.Functions
JavaScript lets you create anonymous functions.
-var avg = function() { +var avg = function() { var sum = 0; for (var i = 0, j = arguments.length; i < j; i++) { sum += arguments[i]; @@ -681,7 +681,7 @@Functions
This is semantically equivalent to the
-function avg()
form. It's extremely powerful, as it lets you put a full function definition anywhere that you would normally put an expression. This enables all sorts of clever tricks. Here's a way of "hiding" some local variables — like block scope in C:var a = 1; +var a = 1; var b = 2; (function() { @@ -695,7 +695,7 @@Functions
JavaScript allows you to call functions recursively. This is particularly useful for dealing with tree structures, such as those found in the browser DOM.
-function countChars(elm) { +function countChars(elm) { if (elm.nodeType == 3) { // TEXT_NODE return elm.nodeValue.length; } @@ -709,7 +709,7 @@Functions
This highlights a potential problem with anonymous functions: how do you call them recursively if they don't have a name? JavaScript lets you name function expressions for this. You can use named IIFEs (Immediately Invoked Function Expressions) as shown below:
-var charsInBody = (function counter(elm) { +var charsInBody = (function counter(elm) { if (elm.nodeType == 3) { // TEXT_NODE return elm.nodeValue.length; } @@ -731,7 +731,7 @@Custom objects
In classic Object Oriented Programming, objects are collections of data and methods that operate on that data. JavaScript is a prototype-based language that contains no class statement, as you'd find in C++ or Java (this is sometimes confusing for programmers accustomed to languages with a class statement). Instead, JavaScript uses functions as classes. Let's consider a person object with first and last name fields. There are two ways in which the name might be displayed: as "first last" or as "last, first". Using the functions and objects that we've discussed previously, we could display the data like this:
-function makePerson(first, last) { +function makePerson(first, last) { return { first: first, last: last @@ -751,7 +751,7 @@Custom objects
This works, but it's pretty ugly. You end up with dozens of functions in your global namespace. What we really need is a way to attach a function to an object. Since functions are objects, this is easy:
-function makePerson(first, last) { +function makePerson(first, last) { return { first: first, last: last, @@ -773,7 +773,7 @@Custom objects
Note that
-this
is a frequent cause of mistakes. For example:var s = makePerson('Simon', 'Willison'); +var s = makePerson('Simon', 'Willison'); var fullName = s.fullName; fullName(); // undefined undefined@@ -782,7 +782,7 @@Custom objects
We can take advantage of the
-this
keyword to improve ourmakePerson
function:function Person(first, last) { +function Person(first, last) { this.first = first; this.last = last; this.fullName = function() { @@ -801,7 +801,7 @@Custom objects
Our person objects are getting better, but there are still some ugly edges to them. Every time we create a person object we are creating two brand new function objects within it — wouldn't it be better if this code was shared?
-function personFullName() { +function personFullName() { return this.first + ' ' + this.last; } function personFullNameReversed() { @@ -817,7 +817,7 @@Custom objects
That's better: we are creating the method functions only once, and assigning references to them inside the constructor. Can we do any better than that? The answer is yes:
-function Person(first, last) { +function Person(first, last) { this.first = first; this.last = last; } @@ -833,7 +833,7 @@Custom objects
This is an incredibly powerful tool. JavaScript lets you modify something's prototype at any time in your program, which means you can add extra methods to existing objects at runtime:
-var s = new Person('Simon', 'Willison'); +var s = new Person('Simon', 'Willison'); s.firstNameCaps(); // TypeError on line 1: s.firstNameCaps is not a function Person.prototype.firstNameCaps = function() { @@ -844,7 +844,7 @@Custom objects
Interestingly, you can also add things to the prototype of built-in JavaScript objects. Let's add a method to
-String
that returns that string in reverse:var s = 'Simon'; +var s = 'Simon'; s.reversed(); // TypeError on line 1: s.reversed is not a function String.prototype.reversed = function() { @@ -860,12 +860,12 @@Custom objects
Our new method even works on string literals!
-'This can now be reversed'.reversed(); // desrever eb won nac sihT +'This can now be reversed'.reversed(); // desrever eb won nac sihTAs mentioned before, the prototype forms part of a chain. The root of that chain is
-Object.prototype
, whose methods includetoString()
— it is this method that is called when you try to represent an object as a string. This is useful for debugging ourPerson
objects:var s = new Person('Simon', 'Willison'); +var s = new Person('Simon', 'Willison'); s.toString(); // [object Object] Person.prototype.toString = function() { @@ -877,7 +877,7 @@Custom objects
Remember how
-avg.apply()
had a null first argument? We can revisit that now. The first argument toapply()
is the object that should be treated as 'this
'. For example, here's a trivial implementation ofnew
:function trivialNew(constructor, ...args) { +function trivialNew(constructor, ...args) { var o = {}; // Create an object constructor.apply(o, args); return o; @@ -888,15 +888,15 @@Custom objects
Calling
-var bill = trivialNew(Person, 'William', 'Orange');+var bill = trivialNew(Person, 'William', 'Orange');is therefore almost equivalent to
-var bill = new Person('William', 'Orange');+var bill = new Person('William', 'Orange');-
apply()
has a sister function namedcall
, which again lets you setthis
but takes an expanded argument list as opposed to an array.function lastNameCaps() { +function lastNameCaps() { return this.last.toUpperCase(); } var s = new Person('Simon', 'Willison'); @@ -910,7 +910,7 @@Inner functions
JavaScript function declarations are allowed inside other functions. We've seen this once before, with an earlier
-makePerson()
function. An important detail of nested functions in JavaScript is that they can access variables in their parent function's scope:function parentFunc() { +function parentFunc() { var a = 1; function nestedFunc() { @@ -929,7 +929,7 @@Closures
This leads us to one of the most powerful abstractions that JavaScript has to offer — but also the most potentially confusing. What does this do?
-function makeAdder(a) { +function makeAdder(a) { return function(b) { return a + b; }; @@ -944,7 +944,7 @@Closures
What's happening here is pretty much the same as was happening with the inner functions earlier on: a function defined inside another function has access to the outer function's variables. The only difference here is that the outer function has returned, and hence common sense would seem to dictate that its local variables no longer exist. But they do still exist — otherwise, the adder functions would be unable to work. What's more, there are two different "copies" of
-makeAdder()
's local variables — one in whicha
is 5 and the other one wherea
is 20. So the result of that function calls is as follows:add5(6); // returns 11 +add5(6); // returns 11 add20(7); // returns 27diff --git a/files/en-us/web/javascript/closures/index.html b/files/en-us/web/javascript/closures/index.html index 4c5691a3810cb8e..9da4b52045d683f 100644 --- a/files/en-us/web/javascript/closures/index.html +++ b/files/en-us/web/javascript/closures/index.html @@ -17,7 +17,7 @@Lexical scoping
Consider the following example code:
-function init() { +function init() { var name = 'Mozilla'; // name is a local variable created by init function displayName() { // displayName() is the inner function, a closure alert(name); // use variable declared in the parent function @@ -34,7 +34,7 @@Closure
Consider the following code example:
-function makeFunc() { +function makeFunc() { var name = 'Mozilla'; function displayName() { alert(name); @@ -54,7 +54,7 @@Closure
Here's a slightly more interesting example—a
-makeAdder
function:function makeAdder(x) { +function makeAdder(x) { return function(y) { return x + y; }; @@ -83,7 +83,7 @@Practical closures
For instance, suppose we want to add buttons to a page to adjust the text size. One way of doing this is to specify the font-size of the
-body
element (in pixels), and then set the size of the other elements on the page (such as headers) using the relativeem
unit:body { +body { font-family: Helvetica, Arial, sans-serif; font-size: 12px; } @@ -101,7 +101,7 @@Practical closures
Here's the JavaScript:
-function makeSizer(size) { +function makeSizer(size) { return function() { document.body.style.fontSize = size + 'px'; }; @@ -114,12 +114,12 @@Practical closures
-
size12
,size14
, andsize16
are now functions that resize the body text to 12, 14, and 16 pixels, respectively. You can attach them to buttons (in this case hyperlinks) as demonstrated in the following code example.document.getElementById('size-12').onclick = size12; +document.getElementById('size-12').onclick = size12; document.getElementById('size-14').onclick = size14; document.getElementById('size-16').onclick = size16;-<a href="#" id="size-12">12</a> +<a href="#" id="size-12">12</a> <a href="#" id="size-14">14</a> <a href="#" id="size-16">16</a>@@ -134,7 +134,7 @@Emulating private methods with
The following code illustrates how to use closures to define public functions that can access private functions and variables. Note that these closures follow the Module Design Pattern.
-var counter = (function() { +var counter = (function() { var privateCounter = 0; function changeBy(val) { privateCounter += val; @@ -171,7 +171,7 @@Emulating private methods with
Those three public functions are closures that share the same lexical environment. Thanks to JavaScript's lexical scoping, they each have access to the
-privateCounter
variable and thechangeBy
function.var makeCounter = function() { +var makeCounter = function() { var privateCounter = 0; function changeBy(val) { privateCounter += val; @@ -223,7 +223,7 @@Closure Scope Chain
A common mistake is not realizing that in the case where the outer function is itself a nested function, access to the outer function's scope includes the enclosing scope of the outer function—effectively creating a chain of function scopes. To demonstrate, consider the following example code.
-// global scope +// global scope var e = 10; function sum(a){ return function(b){ @@ -268,13 +268,13 @@Creating closures in loops:
Prior to the introduction of the
-let
keyword in ECMAScript 2015, a common problem with closures occurred when you created them inside a loop. To demonstrate, consider the following example code.<p id="help">Helpful notes will appear here</p> +<p id="help">Helpful notes will appear here</p> <p>E-mail: <input type="text" id="email" name="email"></p> <p>Name: <input type="text" id="name" name="name"></p> <p>Age: <input type="text" id="age" name="age"></p>-function showHelp(help) { +function showHelp(help) { document.getElementById('help').textContent = help; } @@ -306,7 +306,7 @@Creating closures in loops:
One solution in this case is to use more closures: in particular, to use a function factory as described earlier:
-function showHelp(help) { +function showHelp(help) { document.getElementById('help').textContent = help; } @@ -338,7 +338,7 @@Creating closures in loops:
One other way to write the above using anonymous closures is:
-function showHelp(help) { +function showHelp(help) { document.getElementById('help').textContent = help; } @@ -363,7 +363,7 @@Creating closures in loops:
If you don't want to use more closures, you can use the
-let
keyword introduced in ES2015 :function showHelp(help) { +function showHelp(help) { document.getElementById('help').textContent = help; } @@ -388,7 +388,7 @@Creating closures in loops:
Another alternative could be to use
-forEach()
to iterate over thehelpText
array and attach a listener to each<input>
, as shown:function showHelp(help) { +function showHelp(help) { document.getElementById('help').textContent = help; } @@ -416,7 +416,7 @@Performance considerations
Consider the following case:
-function MyObject(name, message) { +function MyObject(name, message) { this.name = name.toString(); this.message = message.toString(); this.getName = function() { @@ -431,7 +431,7 @@Performance considerations
Because the previous code does not take advantage of the benefits of using closures in this particular instance, we could instead rewrite it to avoid using closure as follows:
-function MyObject(name, message) { +function MyObject(name, message) { this.name = name.toString(); this.message = message.toString(); } @@ -447,7 +447,7 @@Performance considerations
However, redefining the prototype is not recommended. The following example instead appends to the existing prototype:
-function MyObject(name, message) { +function MyObject(name, message) { this.name = name.toString(); this.message = message.toString(); } diff --git a/files/en-us/web/javascript/data_structures/index.html b/files/en-us/web/javascript/data_structures/index.html index c30f8722842da17..c226bd759fd8bb2 100644 --- a/files/en-us/web/javascript/data_structures/index.html +++ b/files/en-us/web/javascript/data_structures/index.html @@ -15,7 +15,7 @@Dynamic typing
JavaScript is a loosely typed and dynamic language. Variables in JavaScript are not directly associated with any particular value type, and any variable can be assigned (and re-assigned) values of all types:
-let foo = 42; // foo is now a number +let foo = 42; // foo is now a number foo = 'bar'; // foo is now a string foo = true; // foo is now a boolean@@ -87,7 +87,7 @@Number type
In the praxis, this has almost no impact. For example,
-+0 === -0
istrue
. However, you are able to notice this when you divide by zero:> 42 / +0 +> 42 / +0 Infinity > 42 / -0 -Infinity @@ -111,7 +111,7 @@BigInt type
This example demonstrates, where incrementing the {{jsxref("Number.MAX_SAFE_INTEGER")}} returns the expected result:
-> const x = 2n ** 53n; +> const x = 2n ** 53n; 9007199254740992n > const y = x + 1n; 9007199254740993n diff --git a/files/en-us/web/javascript/equality_comparisons_and_sameness/index.html b/files/en-us/web/javascript/equality_comparisons_and_sameness/index.html index c95a35034548b93..deb72033bc02848 100644 --- a/files/en-us/web/javascript/equality_comparisons_and_sameness/index.html +++ b/files/en-us/web/javascript/equality_comparisons_and_sameness/index.html @@ -46,7 +46,7 @@Strict equality using
===
Strict equality compares two values for equality. Neither value is implicitly converted to some other value before being compared. If the values have different types, the values are considered unequal. If the values have the same type, are not numbers, and have the same value, they're considered equal. Finally, if both values are numbers, they're considered equal if they're both not
-NaN
and are the same value, or if one is+0
and one is-0
.var num = 0; +var num = 0; var obj = new String('0'); var str = '0'; @@ -150,7 +150,7 @@Loose equality using ==
Traditionally, and according to ECMAScript, all objects are loosely unequal to
-undefined
andnull
. But most browsers permit a very narrow class of objects (specifically, thedocument.all
object for any page), in some contexts, to act as if they emulate the valueundefined
. Loose equality is one such context:null == A
andundefined == A
evaluate to true if, and only if, A is an object that emulatesundefined
. In all other cases an object is never loosely equal toundefined
ornull
.var num = 0; +var num = 0; var obj = new String('0'); var str = '0'; @@ -174,7 +174,7 @@Same-value equality
Same-value equality addresses a final use case: determining whether two values are functionally identical in all contexts. (This use case demonstrates an instance of the Liskov substitution principle.) One instance occurs when an attempt is made to mutate an immutable property:
-// Add an immutable NEGATIVE_ZERO property to the Number constructor. +// Add an immutable NEGATIVE_ZERO property to the Number constructor. Object.defineProperty(Number, 'NEGATIVE_ZERO', { value: -0, writable: false, configurable: false, enumerable: false }); @@ -436,7 +436,7 @@When to use {{jsxref("
- (unary negation)
- -
@@ -467,7 +467,7 @@let stoppingForce = obj.mass * -obj.velocity;+let stoppingForce = obj.mass * -obj.velocity;If
obj.velocity
is0
(or computes to0
), a-0
is introduced at that place and propagates out intostoppingForce
.Caveat: {{jsxref("Object.is")}} and NaN<
The {{jsxref("Object.is")}} specification treats all instances of {{jsxref("NaN")}} as the same object. However, since typed arrays are available, we can have distinct instances, which don't behave identically in all contexts. For example:
-var f2b = x => new Uint8Array(new Float64Array([x]).buffer); +var f2b = x => new Uint8Array(new Float64Array([x]).buffer); var b2f = x => new Float64Array(x.buffer)[0]; var n = f2b(NaN); n[0] = 1; diff --git a/files/en-us/web/javascript/guide/control_flow_and_error_handling/index.html b/files/en-us/web/javascript/guide/control_flow_and_error_handling/index.html index ea8f307db3254f4..53a7f272d8a0905 100644 --- a/files/en-us/web/javascript/guide/control_flow_and_error_handling/index.html +++ b/files/en-us/web/javascript/guide/control_flow_and_error_handling/index.html @@ -34,7 +34,7 @@Block statement
The most basic statement is a block statement, which is used to group statements. The block is delimited by a pair of curly brackets:
-{ +{ statement_1; statement_2; ⋮ @@ -95,7 +95,7 @@
if...else
statementAn
-if
statement looks like this:if (condition) { +if (condition) { statement_1; } else { statement_2; @@ -115,7 +115,7 @@
if...else
statementYou can also compound the statements using
-else if
to have multiple conditions tested in sequence, as follows:if (condition_1) { +if (condition_1) { statement_1; } else if (condition_2) { statement_2; @@ -135,7 +135,7 @@Best practice
In general, it's good practice to always use block statements—especially when nesting
-if
statements:if (condition) { +if (condition) { statement_1_runs_if_condition_is_true; statement_2_runs_if_condition_is_true; } else { @@ -219,7 +219,7 @@
switch
statementA
-switch
statement looks like this:switch (expression) { +switch (expression) { case label_1: statements_1 [break;] @@ -327,7 +327,7 @@
throw
statementUse the
-throw
statement to throw an exception. Athrow
statement specifies the value to be thrown:throw expression; +throw expression;You may throw any expression, not just expressions of a specific type. The following @@ -410,7 +410,7 @@
The
catch
blockYou can use a
-catch
block to handle all exceptions that may be generated in thetry
block.catch (catchID) { +catch (catchID) { statements }diff --git a/files/en-us/web/javascript/guide/expressions_and_operators/index.html b/files/en-us/web/javascript/guide/expressions_and_operators/index.html index e5e77750f3ce848..145d64589af016a 100644 --- a/files/en-us/web/javascript/guide/expressions_and_operators/index.html +++ b/files/en-us/web/javascript/guide/expressions_and_operators/index.html @@ -41,19 +41,19 @@Operators
ternary operator, the conditional operator. A binary operator requires two operands, one before the operator and one after the operator: -operand1 operator operand2 +operand1 operator operand2For example,
3+4
orx*y
.A unary operator requires a single operand, either before or after the operator:
-operator operand +operator operandor
-operand operator +operand operatorFor example,
@@ -198,7 +198,7 @@x++
or++x
.Return value and chaining
Like most expressions, assignments like
-x = y
have a return value. It can be retrieved by e.g. assigning the expression or logging it:const z = (x = y); // Or equivalently: const z = x = y; +const z = (x = y); // Or equivalently: const z = x = y; console.log(z); // Log the return value of the assignment x = y. console.log(x = y); // Or log the return value directly. @@ -235,7 +235,7 @@Destructuring
data from arrays or objects using a syntax that mirrors the construction of array and object literals. -var foo = ['one', 'two', 'three']; +var foo = ['one', 'two', 'three']; // without destructuring var one = foo[0]; @@ -258,7 +258,7 @@Comparison operators
not attempt to convert the operands to compatible types before checking equality. The following table describes the comparison operators in terms of this sample code: -var var1 = 3; +var var1 = 3; var var2 = 4;@@ -363,7 +363,7 @@Arithmetic operators
other programming languages when used with floating point numbers (in particular, note that division by zero produces {{jsxref("Infinity")}}). For example: -1 / 2; // 0.5 +1 / 2; // 0.5 1 / 2 == 1.0 / 2.0; // this is true@@ -521,7 +521,7 @@Bitwise logical operators
bits (zeros and ones). Numbers with more than 32 bits get their most significant bits discarded. For example, the following integer with more than 32 bits will be converted to a 32 bit integer: -Before: 1110 0110 1111 1010 0000 0000 0000 0110 0000 0000 0001 +Before: 1110 0110 1111 1010 0000 0000 0000 0110 0000 0000 0001 After: 1010 0000 0000 0000 0110 0000 0000 0001Each bit in the first operand is paired with the corresponding bit in the second @@ -687,7 +687,7 @@ Logical operators
The following code shows examples of the
-&&
(logical AND) operator.var a1 = true && true; // t && t returns true +var a1 = true && true; // t && t returns true var a2 = true && false; // t && f returns false var a3 = false && true; // f && t returns false var a4 = false && (3 == 4); // f && f returns false @@ -698,7 +698,7 @@Logical operators
The following code shows examples of the || (logical OR) operator.
-var o1 = true || true; // t || t returns true +var o1 = true || true; // t || t returns true var o2 = false || true; // f || t returns true var o3 = true || false; // t || f returns true var o4 = false || (3 == 4); // f || f returns false @@ -709,7 +709,7 @@Logical operators
The following code shows examples of the ! (logical NOT) operator.
-var n1 = !true; // !t returns false +var n1 = !true; // !t returns false var n2 = !false; // !f returns true var n3 = !'Cat'; // !t returns false@@ -750,13 +750,13 @@String operators
For example,
console.log('my ' + 'string'); // console logs the string "my string".+ class="brush: js">console.log('my ' + 'string'); // console logs the string "my string".The shorthand assignment operator += can also be used to concatenate strings.
For example,
-var mystring = 'alpha'; +var mystring = 'alpha'; mystring += 'bet'; // evaluates to "alphabet" and assigns this value to mystring.Conditional (ternary) operator
@@ -766,7 +766,7 @@Conditional (ternary) operator
operator is the only JavaScript operator that takes three operands. The operator can have one of two values based on a condition. The syntax is: -condition ? val1 : val2 +condition ? val1 : val2If
condition
is true, the operator has the value ofval1
. @@ -775,7 +775,7 @@Conditional (ternary) operator
For example,
-var status = (age >= 18) ? 'adult' : 'minor'; +var status = (age >= 18) ? 'adult' : 'minor';This statement assigns the value "adult" to the variable
status
if @@ -795,7 +795,7 @@Comma operator
following code uses the comma operator to update two variables at once. The code prints the values of the diagonal elements in the array: -var x = [0,1,2,3,4,5,6,7,8,9] +var x = [0,1,2,3,4,5,6,7,8,9] var a = [x, x, x, x, x]; for (var i = 0, j = 9; i <= j; i++, j--) @@ -813,7 +813,7 @@
delete
delete
operator deletes an object's property. The syntax is: -delete object.property; +delete object.property; delete object[propertyKey]; delete objectName[index]; delete property; // legal only within a with statement @@ -833,7 +833,7 @@
delete
delete
operator returnstrue
if the operation is possible; it returnsfalse
if the operation is not possible. -x = 42; // implicitly creates window.x +x = 42; // implicitly creates window.x var y = 43; var myobj = {h: 4}; // create object with property h @@ -859,7 +859,7 @@
typeof
The
-typeof
operator is used in either of the following ways:typeof operand +typeof operand typeof (operand)@@ -869,7 +869,7 @@
typeof
Suppose you define the following variables:
-var myFun = new Function('5 + 2'); +var myFun = new Function('5 + 2'); var shape = 'round'; var size = 1; var foo = ['Apple', 'Mango', 'Orange']; @@ -878,7 +878,7 @@
typeof
The
-typeof
operator returns the following results for these variables:typeof myFun; // returns "function" +typeof myFun; // returns "function" typeof shape; // returns "string" typeof size; // returns "number" typeof foo; // returns "object" @@ -889,21 +889,21 @@
typeof
For the keywords
-true
andnull
, thetypeof
operator returns the following results:typeof true; // returns "boolean" +typeof true; // returns "boolean" typeof null; // returns "object"For a number or string, the
-typeof
operator returns the following results:typeof 62; // returns "number" +typeof 62; // returns "number" typeof 'Hello world'; // returns "string"For property values, the
-typeof
operator returns the type of value the property contains:typeof document.lastModified; // returns "string" +typeof document.lastModified; // returns "string" typeof window.length; // returns "number" typeof Math.LN2; // returns "number"@@ -911,7 +911,7 @@
typeof
For methods and functions, the
-typeof
operator returns results as follows:typeof blur; // returns "function" +typeof blur; // returns "function" typeof eval; // returns "function" typeof parseInt; // returns "function" typeof shape.split; // returns "function" @@ -920,7 +920,7 @@
typeof
For predefined objects, the
-typeof
operator returns results as follows:typeof Date; // returns "function" +typeof Date; // returns "function" typeof Function; // returns "function" typeof Math; // returns "object" typeof Option; // returns "function" @@ -932,7 +932,7 @@
void
The
-void
operator is used in either of the following ways:void (expression) +void (expression) void expression@@ -952,7 +952,7 @@operator returns
in
true
if the specified property is in the specified object. The syntax is: -propNameOrNumber in objectName +propNameOrNumber in objectNamewhere
propNameOrNumber
is a string, numeric, or symbol expression @@ -961,7 +961,7 @@
in
The following examples show some uses of the
-in
operator.// Arrays +// Arrays var trees = ['redwood', 'bay', 'cedar', 'oak', 'maple']; 0 in trees; // returns true 3 in trees; // returns true @@ -988,7 +988,7 @@operator returns
instanceof
true
if the specified object is of the specified object type. The syntax is: -objectName instanceof objectType +objectName instanceof objectTypewhere
objectName
is the name of the object to compare to @@ -1003,7 +1003,7 @@
instanceof
theDay
is aDate
object. BecausetheDay
is aDate
object, the statements in theif
statement execute. -var theDay = new Date(1995, 12, 17); +var theDay = new Date(1995, 12, 17); if (theDay instanceof Date) { // statements to execute } @@ -1140,14 +1140,14 @@the calling object in a method. Use
this
this
either with the dot or the bracket notation: -this['propertyName'] +this['propertyName'] this.propertyNameSuppose a function called
-validate
validates an object'svalue
property, given the object and the high and low values:function validate(obj, lowval, hival) { +function validate(obj, lowval, hival) { if ((obj.value < lowval) || (obj.value > hival)) console.log('Invalid Value!'); } @@ -1157,7 +1157,7 @@handler, using
this
this
to pass it to the form element, as in the following example: -<p>Enter a number between 18 and 99:</p> +<p>Enter a number between 18 and 99:</p> <input type="text" name="age" size=3 onChange="validate(this, 18, 99);">@@ -1167,7 +1167,7 @@Grouping operator
expressions. For example, you can override multiplication and division first, then addition and subtraction to evaluate addition first. -var a = 1; +var a = 1; var b = 2; var c = 3; @@ -1195,7 +1195,7 @@operator to create an instance of a user-defined object type or of one of the built-in object types. Use
new
new
as follows: -var objectName = new objectType([param1, param2, ..., paramN]); +var objectName = new objectType([param1, param2, ..., paramN]);super
@@ -1205,7 +1205,7 @@super
href="/en-US/docs/Web/JavaScript/Reference/Classes">classes to call the parent constructor, for example. -super([arguments]); // calls the parent constructor. +super([arguments]); // calls the parent constructor. super.functionOnParent([arguments]);diff --git a/files/en-us/web/javascript/guide/functions/index.html b/files/en-us/web/javascript/guide/functions/index.html index 69b046ad8adf8ae..92792946496e804 100644 --- a/files/en-us/web/javascript/guide/functions/index.html +++ b/files/en-us/web/javascript/guide/functions/index.html @@ -28,21 +28,21 @@Function declarations
For example, the following code defines a simple function named
-square
:function square(number) { +function square(number) { return number * number; }The function
-square
takes one parameter, callednumber
. The function consists of one statement that says to return the parameter of the function (that is,number
) multiplied by itself. The statementreturn
specifies the value returned by the function:return number * number; +return number * number;Primitive parameters (such as a number) are passed to functions by value; the value is passed to the function, but if the function changes the value of the parameter, this change is not reflected globally or in the calling function.
If you pass an object (i.e. a non-primitive value, such as {{jsxref("Array")}} or a user-defined object) as a parameter and the function changes the object's properties, that change is visible outside the function, as shown in the following example:
-function myFunc(theObject) { +function myFunc(theObject) { theObject.make = 'Toyota'; } @@ -62,19 +62,19 @@Function expressions
Such a function can be anonymous; it does not have to have a name. For example, the function
-square
could have been defined as:const square = function(number) { return number * number } +const square = function(number) { return number * number } var x = square(4) // x gets the value 16However, a name can be provided with a function expression. Providing a name allows the function to refer to itself, and also makes it easier to identify the function in a debugger's stack traces:
-const factorial = function fac(n) { return n < 2 ? 1 : n * fac(n - 1) } +const factorial = function fac(n) { return n < 2 ? 1 : n * fac(n - 1) } console.log(factorial(3))Function expressions are convenient when passing a function as an argument to another function. The following example shows a
-map
function that should receive a function as first argument and an array as second argument.function map(f, a) { +function map(f, a) { let result = []; // Create a new Array let i; // Declare variable for (i = 0; i != a.length; i++) @@ -85,7 +85,7 @@Function expressions
In the following code, the function receives a function defined by a function expression and executes it for every element of the array received as a second argument.
-function map(f, a) { +function map(f, a) { let result = []; // Create a new Array let i; // Declare variable for (i = 0; i != a.length; i++) @@ -103,7 +103,7 @@Function expressions
In JavaScript, a function can be defined based on a condition. For example, the following function definition defines
-myFunc
only ifnum
equals0
:var myFunc; +var myFunc; if (num === 0) { myFunc = function(theObject) { theObject.make = 'Toyota'; @@ -120,14 +120,14 @@Calling functions
Calling the function actually performs the specified actions with the indicated parameters. For example, if you define the function
-square
, you could call it as follows:square(5); +square(5);The preceding statement calls the function with an argument of
5
. The function executes its statements and returns the value25
.Functions must be in scope when they are called, but the function declaration can be hoisted (appear below the call in the code), as in this example:
-console.log(square(5)); +console.log(square(5)); /* ... */ function square(n) { return n * n }@@ -139,7 +139,7 @@Calling functions
This means that function hoisting only works with function declarations—not with function expressions.
-console.log(square) // square is hoisted with an initial value undefined. +console.log(square) // square is hoisted with an initial value undefined. console.log(square(5)) // Uncaught TypeError: square is not a function const square = function(n) { return n * n; @@ -151,7 +151,7 @@Calling functions
A function can call itself. For example, here is a function that computes factorials recursively:
-function factorial(n) { +function factorial(n) { if ((n === 0) || (n === 1)) return 1; else @@ -161,7 +161,7 @@Calling functions
You could then compute the factorials of
-1
through5
as follows:var a, b, c, d, e; +var a, b, c, d, e; a = factorial(1); // a gets the value 1 b = factorial(2); // b gets the value 2 c = factorial(3); // c gets the value 6 @@ -179,7 +179,7 @@Function scope
In other words, a function defined in the global scope can access all variables defined in the global scope. A function defined inside another function can also access all variables defined in its parent function, and any other variables to which the parent function has access.
-// The following variables are defined in the global scope +// The following variables are defined in the global scope var num1 = 20, num2 = 3, name = 'Chamahk'; @@ -220,7 +220,7 @@Recursion
For example, consider the following function definition:
-var foo = function bar() { +var foo = function bar() { // statements go here }@@ -237,7 +237,7 @@Recursion
For example, the following loop...
-var x = 0; +var x = 0; while (x < 10) { // "x < 10" is the loop condition // do stuff x++; @@ -246,7 +246,7 @@Recursion
...can be converted into a recursive function declaration, followed by a call to that function:
-function loop(x) { +function loop(x) { if (x >= 10) // "x >= 10" is the exit condition (equivalent to "!(x < 10)") return; // do stuff @@ -257,7 +257,7 @@Recursion
However, some algorithms cannot be simple iterative loops. For example, getting all the nodes of a tree structure (such as the DOM) is easier via recursion:
-function walkTree(node) { +function walkTree(node) { if (node == null) // return; // do something with node @@ -273,7 +273,7 @@Recursion
In fact, recursion itself uses a stack: the function stack. The stack-like behavior can be seen in the following example:
-function foo(i) { +function foo(i) { if (i < 0) return; console.log('begin: ' + i); @@ -313,7 +313,7 @@Nested functions and closures
The following example shows nested functions:
-function addSquares(a, b) { +function addSquares(a, b) { function square(x) { return x * x; } @@ -326,7 +326,7 @@Nested functions and closures
Since the inner function forms a closure, you can call the outer function and specify arguments for both the outer and inner function:
-function outside(x) { +function outside(x) { function inside(y) { return x + y; } @@ -359,7 +359,7 @@Multiply-nested functions
Consider the following example:
-function A(x) { +function A(x) { function B(y) { function C(z) { console.log(x + y + z); @@ -387,7 +387,7 @@Name conflicts
When two arguments or variables in the scopes of a closure have the same name, there is a name conflict. More nested scopes take precedence. So, the inner-most scope takes the highest precedence, while the outer-most scope takes the lowest. This is the scope chain. The first on the chain is the inner-most scope, and the last is the outer-most scope. Consider the following:
-function outside() { +function outside() { var x = 5; function inside(x) { return x * 2; @@ -408,7 +408,7 @@Closures
Also, since the inner function has access to the scope of the outer function, the variables and functions defined in the outer function will live longer than the duration of the outer function execution, if the inner function manages to survive beyond the life of the outer function. A closure is created when the inner function is somehow made available to any scope outside the outer function.
-var pet = function(name) { // The outer function defines a variable called "name" +var pet = function(name) { // The outer function defines a variable called "name" var getName = function() { return name; // The inner function has access to the "name" variable of the outer //function @@ -422,7 +422,7 @@Closures
It can be much more complex than the code above. An object containing methods for manipulating the inner variables of the outer function can be returned.
-var createPet = function(name) { +var createPet = function(name) { var sex; return { @@ -458,7 +458,7 @@Closures
In the code above, the
-name
variable of the outer function is accessible to the inner functions, and there is no other way to access the inner variables except through the inner functions. The inner variables of the inner functions act as safe stores for the outer arguments and variables. They hold "persistent" and "encapsulated" data for the inner functions to work with. The functions do not even have to be assigned to a variable, or have a name.var getCode = (function() { +var getCode = (function() { var apiCode = '0]Eal(eh&2'; // A code we do not want outsiders to be able to modify... return function() { @@ -474,7 +474,7 @@Closures
If an enclosed function defines a variable with the same name as a variable in the outer scope, then there is no way to refer to the variable in the outer scope again. (The inner scope variable "overrides" the outer one, until the program exits the inner scope.)
-var createPet = function(name) { // The outer function defines a variable called "name". +var createPet = function(name) { // The outer function defines a variable called "name". return { setName: function(name) { // The enclosed function also defines a variable called "name". name = name; // How do we access the "name" defined by the outer function? @@ -488,7 +488,7 @@Using the arguments object
The arguments of a function are maintained in an array-like object. Within a function, you can address the arguments passed to it as follows:
-arguments[i] +arguments[i]where
@@ -497,7 +497,7 @@i
is the ordinal number of the argument, starting at0
. So, the first argument passed to a function would bearguments[0]
. The total number of arguments is indicated byarguments.length
.Using the arguments object
For example, consider a function that concatenates several strings. The only formal argument for the function is a string that specifies the characters that separate the items to concatenate. The function is defined as follows:
-function myConcat(separator) { +function myConcat(separator) { var result = ''; // initialize list var i; // iterate through arguments @@ -510,7 +510,7 @@Using the arguments object
You can pass any number of arguments to this function, and it concatenates each argument into a string "list":
-// returns "red, orange, blue, " +// returns "red, orange, blue, " myConcat(', ', 'red', 'orange', 'blue'); // returns "elephant; giraffe; lion; cheetah; " @@ -540,7 +540,7 @@Without default paramete
In the following example, if no value is provided for
-b
, its value would beundefined
when evaluatinga*b
, and a call tomultiply
would normally have returnedNaN
. However, this is prevented by the second line in this example:function multiply(a, b) { +function multiply(a, b) { b = typeof b !== 'undefined' ? b : 1; return a * b; @@ -553,7 +553,7 @@With default parameters (p
With default parameters, a manual check in the function body is no longer necessary. You can put
-1
as the default value forb
in the function head:function multiply(a, b = 1) { +function multiply(a, b = 1) { return a * b; } @@ -567,7 +567,7 @@Rest parameters
In the following example, the function
-multiply
uses rest parameters to collect arguments from the second one to the end. The function then multiplies these by the first argument .function multiply(multiplier, ...theArgs) { +function multiply(multiplier, ...theArgs) { return theArgs.map(x => multiplier * x); } @@ -584,7 +584,7 @@Shorter functions
In some functional patterns, shorter functions are welcome. Compare:
-var a = [ +var a = [ 'Hydrogen', 'Helium', 'Lithium', @@ -604,7 +604,7 @@No separate
this
Until arrow functions, every new function defined its own
-this
value (a new object in the case of a constructor, undefined in strict mode function calls, the base object if the function is called as an "object method", etc.). This proved to be less than ideal with an object-oriented style of programming.function Person() { +function Person() { // The Person() constructor defines `this` as itself. this.age = 0; @@ -620,7 +620,7 @@No separate
this
In ECMAScript 3/5, this issue was fixed by assigning the value in
-this
to a variable that could be closed over.function Person() { +function Person() { var self = this; // Some choose `that` instead of `self`. // Choose one and be consistent. self.age = 0; @@ -636,7 +636,7 @@No separate
this
An arrow function does not have its own
-this;
thethis
value of the enclosing execution context is used. Thus, in the following code, thethis
within the function that is passed tosetInterval
has the same value asthis
in the enclosing function:function Person() { +function Person() { this.age = 0; setInterval(() => { diff --git a/files/en-us/web/javascript/guide/grammar_and_types/index.html b/files/en-us/web/javascript/guide/grammar_and_types/index.html index a1f6fbeccdc874b..fb3673de3ac27da 100644 --- a/files/en-us/web/javascript/guide/grammar_and_types/index.html +++ b/files/en-us/web/javascript/guide/grammar_and_types/index.html @@ -16,7 +16,7 @@Basics
JavaScript is case-sensitive and uses the Unicode character set. For example, the word Früh (which means "early" in German) could be used as a variable name.
-let Früh = "foobar"+let Früh = "foobar"But, the variable
@@ -36,7 +36,7 @@früh
is not the same asFrüh
because JavaScript is case sensitive.Comments
The syntax of comments is the same as in C++ and in many other languages:
-// a one line comment +// a one line comment /* this is a longer, * multi-line comment @@ -97,7 +97,7 @@Evaluating variables
An attempt to access an undeclared variable results in a {{jsxref("ReferenceError")}} exception being thrown:
-var a; +var a; console.log('The value of a is ' + a); // The value of a is undefined console.log('The value of b is ' + b); // The value of b is undefined @@ -114,7 +114,7 @@Evaluating variables
You can use
-undefined
to determine whether a variable has a value. In the following code, the variableinput
is not assigned a value, and theif
statement evaluates totrue
.var input; +var input; if (input === undefined) { doThis(); } else { @@ -124,18 +124,18 @@Evaluating variables
The
-undefined
value behaves asfalse
when used in a boolean context. For example, the following code executes the functionmyFunction
because themyArray
element isundefined
:var myArray = []; +var myArray = []; if (!myArray[0]) myFunction();The
-undefined
value converts toNaN
when used in numeric context.var a; +var a; a + 2; // Evaluates to NaNWhen you evaluate a {{jsxref("null")}} variable, the null value behaves as
-0
in numeric contexts and asfalse
in boolean contexts. For example:var n = null; +var n = null; console.log(n * 32); // Will log 0 to the console@@ -147,7 +147,7 @@Variable scope
For example, the following code will log
-5
, because the scope ofx
is the global context (or the function context if the code is part of a function). The scope ofx
is not limited to the immediateif
statement block.if (true) { +if (true) { var x = 5; } console.log(x); // x is 5 @@ -155,7 +155,7 @@Variable scope
This behavior changes when using the
-let
declaration (introduced in ECMAScript 2015).if (true) { +if (true) { let y = 5; } console.log(y); // ReferenceError: y is not defined @@ -167,7 +167,7 @@Variable hoisting
This concept is known as hoisting. Variables in JavaScript are, in a sense, "hoisted" (or "lifted") to the top of the function or statement. However, variables that are hoisted return a value of
-undefined
. So even if you declare and initialize after you use or refer to this variable, it still returnsundefined
./** +/** * Example 1 */ console.log(x === undefined); // true @@ -187,7 +187,7 @@Variable hoisting
The above examples will be interpreted the same as:
-/** +/** * Example 1 */ var x; @@ -210,14 +210,14 @@Variable hoisting
In ECMAScript 2015,
-let
andconst
are hoisted but not initialized. Referencing the variable in the block before the variable declaration results in a {{jsxref("ReferenceError")}}, because the variable is in a "temporal dead zone" from the start of the block until the declaration is processed.console.log(x); // ReferenceError +console.log(x); // ReferenceError let x = 3;Function hoisting
In the case of functions, only function declarations are hoisted—but not the function expressions.
-/* Function declaration */ +/* Function declaration */ foo(); // "bar" @@ -248,7 +248,7 @@Constants
The syntax of a constant identifier is the same as any variable identifier: it must start with a letter, underscore, or dollar sign (
-$
), and can contain alphabetic, numeric, or underscore characters.const PI = 3.14; +const PI = 3.14;A constant cannot change value through assignment or be re-declared while the script is running. It must be initialized to a value.
@@ -257,7 +257,7 @@Constants
You cannot declare a constant with the same name as a function or variable in the same scope. For example:
-// THIS WILL CAUSE AN ERROR +// THIS WILL CAUSE AN ERROR function f() {}; const f = 5; @@ -272,12 +272,12 @@Constants
However, the properties of objects assigned to constants are not protected, so the following statement is executed without problems.
-const MY_OBJECT = {'key': 'value'}; +const MY_OBJECT = {'key': 'value'}; MY_OBJECT.key = 'otherValue';Also, the contents of an array are not protected, so the following statement is executed without problems.
-const MY_ARRAY = ['HTML','CSS']; +const MY_ARRAY = ['HTML','CSS']; MY_ARRAY.push('JAVASCRIPT'); console.log(MY_ARRAY); //logs ['HTML','CSS','JAVASCRIPT'];@@ -311,12 +311,12 @@Data type conversion
So, for example, you could define a variable as follows:
-var answer = 42; +var answer = 42;And later, you could assign the same variable a string value, for example:
-answer = 'Thanks for all the fish...'; +answer = 'Thanks for all the fish...';Because JavaScript is dynamically typed, this assignment does not cause an error message.
@@ -325,13 +325,13 @@Numbers and the '+' operator
In expressions involving numeric and string values with the
-+
operator, JavaScript converts numeric values to strings. For example, consider the following statements:x = 'The answer is ' + 42 // "The answer is 42" +x = 'The answer is ' + 42 // "The answer is 42" y = 42 + ' is the answer' // "42 is the answer"With all other operators, JavaScript does not convert numeric values to strings. For example:
-'37' - 7 // 30 +'37' - 7 // 30 '37' + 7 // "377"@@ -350,11 +350,11 @@Converting strings to numbers
Additionally, a best practice for
-parseInt
is to always include the radix parameter. The radix parameter is used to specify which numerical system is to be used.parseInt('101', 2) // 5+parseInt('101', 2) // 5An alternative method of retrieving a number from a string is with the
-+
(unary plus) operator:'1.1' + '1.1' // '1.11.1' +'1.1' + '1.1' // '1.11.1' (+'1.1') + (+'1.1') // 2.2 // Note: the parentheses are added for clarity, not required.@@ -378,7 +378,7 @@Array literals
The following example creates the
-coffees
array with three elements and alength
of three:let coffees = ['French Roast', 'Colombian', 'Kona']; +let coffees = ['French Roast', 'Colombian', 'Kona'];@@ -395,7 +395,7 @@-Extra commas in array literals
You do not have to specify all elements in an array literal. If you put two commas in a row, the array fills in the value
-undefined
for the unspecified elements. The following example creates thefish
array:let fish = ['Lion', , 'Angel']; +let fish = ['Lion', , 'Angel'];This array has two elements with values and one empty element:
@@ -414,17 +414,17 @@Extra commas in array literals
Note : Trailing commas can create errors in older browser versions and it is a best practice to remove them.
let myList = ['home', , 'school', ]; +let myList = ['home', , 'school', ];In the following example, the
-length
of the array is four, andmyList[0]
andmyList[2]
are missing.let myList = [ ,'home', , 'school']; +let myList = [ ,'home', , 'school'];In the following example, the
-length
of the array is four, andmyList[1]
andmyList[3]
are missing. Only the last comma is ignored.let myList = ['home', , 'school', , ]; +let myList = ['home', , 'school', , ];Understanding the behavior of extra commas is important to understanding JavaScript as a language.
@@ -456,7 +456,7 @@Numeric literals
Some examples of numeric literals are:
-0, 117, -345, 123456789123456789n (decimal, base 10) +0, 117, -345, 123456789123456789n (decimal, base 10) 015, 0001, -0o77, 0o777777777777n (octal, base 8) 0x1123, 0x00111, -0xF1A7, 0x123456789ABCDEFn (hexadecimal, "hex" or base 16) 0b11, 0b0011, -0b11, 0b11101001010101010101n (binary, base 2) @@ -479,12 +479,12 @@Floating-point literals
More succinctly, the syntax is:
-[(+|-)][digits].[digits][(E|e)[(+|-)]digits] +[(+|-)][digits].[digits][(E|e)[(+|-)]digits]For example:
-3.1415926 +3.1415926 -.123456789 -3.1E+12 .1e-23 @@ -500,7 +500,7 @@Object literals
The following is an example of an object literal. The first element of the
-car
object defines a property,myCar
, and assigns to it a new string, "Saturn
"; the second element, thegetCar
property, is immediately assigned the result of invoking the function(carTypes("Honda"))
; the third element, thespecial
property, uses an existing variable (sales
).var sales = 'Toyota'; +var sales = 'Toyota'; function carTypes(name) { if (name === 'Honda') { @@ -519,7 +519,7 @@Object literals
Additionally, you can use a numeric or string literal for the name of a property or nest an object inside another. The following example uses these options.
-var car = { manyCars: {a: 'Saab', b: 'Jeep'}, 7: 'Mazda' }; +var car = { manyCars: {a: 'Saab', b: 'Jeep'}, 7: 'Mazda' }; console.log(car.manyCars.b); // Jeep console.log(car[7]); // Mazda @@ -529,7 +529,7 @@Object literals
Property names that are not valid identifiers cannot be accessed as a dot (
-.
) property, but can be accessed and set with the array-like notation("[]
").var unusualPropertyNames = { +var unusualPropertyNames = { '': 'An empty string', '!': 'Bang!' } @@ -544,7 +544,7 @@Enhanced Object literals
Together, these also bring object literals and class declarations closer together, and allow object-based design to benefit from some of the same conveniences.
-var obj = { +var obj = { // __proto__ __proto__: theProtoObj, // Shorthand for ‘handler: handler’ @@ -563,7 +563,7 @@RegExp literals
A regex literal (which is defined in detail later) is a pattern enclosed between slashes. The following is an example of a regex literal.
-var re = /ab+c/;+var re = /ab+c/;String literals
@@ -571,7 +571,7 @@String literals
The following are examples of string literals:
-'foo' +'foo' "bar" '1234' 'one line \n another line' @@ -580,7 +580,7 @@String literals
You can call any of the {{jsxref("String")}} object's methods on a string literal value. JavaScript automatically converts the string literal to a temporary String object, calls the method, then discards the temporary String object. You can also use the
-String.length
property with a string literal:// Will print the number of symbols in the string including whitespace. +// Will print the number of symbols in the string including whitespace. console.log("John's cat".length) // In this case, 10.@@ -590,7 +590,7 @@String literals
Optionally, a tag can be added to allow the string construction to be customized, avoiding injection attacks, or constructing higher-level data structures from string contents.
-// Basic literal string creation +// Basic literal string creation `In JavaScript '\n' is a line-feed.` // Multiline strings @@ -615,7 +615,7 @@Using special characters in strings
In addition to ordinary characters, you can also include special characters in strings, as shown in the following example.
-'one line \n another line' +'one line \n another line'The following table lists the special characters that you can use in JavaScript strings.
@@ -700,23 +700,23 @@Escaping characters
You can insert a quotation mark inside a string by preceding it with a backslash. This is known as escaping the quotation mark. For example:
-var quote = "He read \"The Cremation of Sam McGee\" by R.W. Service."; +var quote = "He read \"The Cremation of Sam McGee\" by R.W. Service."; console.log(quote);The result of this would be:
-He read "The Cremation of Sam McGee" by R.W. Service. +He read "The Cremation of Sam McGee" by R.W. Service.To include a literal backslash inside a string, you must escape the backslash character. For example, to assign the file path
-c:\temp
to a string, use the following:var home = 'c:\\temp'; +var home = 'c:\\temp';You can also escape line breaks by preceding them with backslash. The backslash and line break are both removed from the value of the string.
-var str = 'this string \ +var str = 'this string \ is broken \ across multiple \ lines.' @@ -725,7 +725,7 @@Escaping characters
Although JavaScript does not have "heredoc" syntax, you can get close by adding a line break escape and an escaped line break at the end of each line:
-var poem = +var poem = 'Roses are red,\n\ Violets are blue.\n\ Sugar is sweet,\n\ @@ -734,7 +734,7 @@Escaping characters
ECMAScript 2015 introduces a new type of literal, namely template literals. This allows for many new features, including multiline strings!
-var poem = +var poem = `Roses are red, Violets are blue. Sugar is sweet, diff --git a/files/en-us/web/javascript/guide/indexed_collections/index.html b/files/en-us/web/javascript/guide/indexed_collections/index.html index 93d6407f6d8fb28..6050334bff16af8 100644 --- a/files/en-us/web/javascript/guide/indexed_collections/index.html +++ b/files/en-us/web/javascript/guide/indexed_collections/index.html @@ -22,7 +22,7 @@Creating an array
The following statements create equivalent arrays:
-let arr = new Array(element0, element1, ..., elementN) +let arr = new Array(element0, element1, ..., elementN) let arr = Array(element0, element1, ..., elementN) let arr = [element0, element1, ..., elementN]@@ -33,7 +33,7 @@Creating an array
To create an array with non-zero length, but without any items, either of the following can be used:
-// This... +// This... let arr = new Array(arrayLength) // ...results in the same array as this @@ -50,7 +50,7 @@Creating an array
In addition to a newly defined variable as shown above, arrays can also be assigned as a property of a new or an existing object:
-let obj = {} +let obj = {} // ... obj.prop = [element0, element1, ..., elementN] @@ -60,7 +60,7 @@Creating an array
If you wish to initialize an array with a single element, and the element happens to be a
-Number
, you must use the bracket syntax. When a singleNumber
value is passed to theArray()
constructor or function, it is interpreted as anarrayLength
, not as a single element.let arr = [42] // Creates an array with only one element: +let arr = [42] // Creates an array with only one element: // the number 42. let arr = Array(42) // Creates an array with no elements @@ -73,20 +73,20 @@Creating an array
Calling
-Array(N)
results in aRangeError
, ifN
is a non-whole number whose fractional portion is non-zero. The following example illustrates this behavior.let arr = Array(9.3) // RangeError: Invalid array length +let arr = Array(9.3) // RangeError: Invalid array lengthIf your code needs to create arrays with single elements of an arbitrary data type, it is safer to use array literals. Alternatively, create an empty array first before adding the single element to it.
In ES2015, you can use the {{jsxref("Array.of")}} static method to create arrays with single element.
-let wisenArray = Array.of(9.3) // wisenArray contains only one element 9.3+let wisenArray = Array.of(9.3) // wisenArray contains only one element 9.3Referring to array elements
Because elements are also properties, you can access the using property accessors. Suppose you define the following array:
-let myArray = ['Wind', 'Rain', 'Fire'] +let myArray = ['Wind', 'Rain', 'Fire']You can refer to the first element of the array as
@@ -94,7 +94,7 @@myArray[0]
, the second element of the array asmyArray[1]
, etc… The index of the elements begins with zero.Referring to array elements
Note: You can also use property accessors to access other properties of the array, like with an object.
-let arr = ['one', 'two', 'three'] +let arr = ['one', 'two', 'three'] arr[2] // three arr['length'] // 3@@ -104,7 +104,7 @@Populating an array
You can populate an array by assigning values to its elements. For example:
-let emp = [] +let emp = [] emp[0] = 'Casey Jones' emp[1] = 'Phil Lesh' emp[2] = 'August West' @@ -113,7 +113,7 @@Populating an array
Note: If you supply a non-integer value to the array operator in the code above, a property will be created in the object representing the array, instead of an array element.
-let arr = [] +let arr = [] arr[3.4] = 'Oranges' console.log(arr.length) // 0 console.log(arr.hasOwnProperty(3.4)) // true @@ -122,7 +122,7 @@Populating an array
You can also populate an array when you create it:
-let myArray = new Array('Hello', myVar, 3.14159) +let myArray = new Array('Hello', myVar, 3.14159) // OR let myArray = ['Mango', 'Apple', 'Orange']@@ -135,7 +135,7 @@Understanding length
Remember, JavaScript Array indexes are 0-based: they start at
-0
, not1
. This means that thelength
property will be one more than the highest index stored in the array:let cats = [] +let cats = [] cats[30] = ['Dusty'] console.log(cats.length) // 31@@ -144,7 +144,7 @@Understanding length
Writing a value that is shorter than the number of stored items truncates the array. Writing
-0
empties it entirely:let cats = ['Dusty', 'Misty', 'Twiggy'] +let cats = ['Dusty', 'Misty', 'Twiggy'] console.log(cats.length) // 3 cats.length = 2 @@ -161,7 +161,7 @@Iterating over arrays
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:
-let colors = ['red', 'green', 'blue'] +let colors = ['red', 'green', 'blue'] for (let i = 0; i < colors.length; i++) { console.log(colors[i]) } @@ -169,7 +169,7 @@Iterating over arrays
If you know that none of the elements in your array evaluate to
-false
in a boolean context—if your array consists only of DOM nodes, for example—you can use a more efficient idiom:let divs = document.getElementsByTagName('div') +let divs = document.getElementsByTagName('div') for (let i = 0, div; div = divs[i]; i++) { /* Process div in some way */ } @@ -179,7 +179,7 @@Iterating over arrays
The {{jsxref("Array.forEach", "forEach()")}} method provides another way of iterating over an array:
-let colors = ['red', 'green', 'blue'] +let colors = ['red', 'green', 'blue'] colors.forEach(function(color) { console.log(color) }) @@ -190,7 +190,7 @@Iterating over arrays
Alternatively, you can shorten the code for the forEach parameter with ES2015 Arrow Functions:
-let colors = ['red', 'green', 'blue'] +let colors = ['red', 'green', 'blue'] colors.forEach(color => console.log(color)) // red // green @@ -201,7 +201,7 @@Iterating over arrays
Note that the elements of an array that are omitted when the array is defined are not listed when iterating by
-forEach
, but are listed whenundefined
has been manually assigned to the element:let array = ['first', 'second', , 'fourth'] +let array = ['first', 'second', , 'fourth'] array.forEach(function(element) { console.log(element) @@ -233,54 +233,54 @@Array methods
{{jsxref("Array.concat", "concat()")}} joins two or more arrays and returns a new array.
-let myArray = new Array('1', '2', '3') +let myArray = new Array('1', '2', '3') myArray = myArray.concat('a', 'b', 'c') // myArray is now ["1", "2", "3", "a", "b", "c"]{{jsxref("Array.join", "join(delimiter = ',')")}} joins all elements of an array into a string.
-let myArray = new Array('Wind', 'Rain', 'Fire') +let myArray = new Array('Wind', 'Rain', 'Fire') let list = myArray.join(' - ') // list is "Wind - Rain - Fire"{{jsxref("Array.push", "push()")}} adds one or more elements to the end of an array and returns the resulting
-length
of the array.let myArray = new Array('1', '2') +let myArray = new Array('1', '2') myArray.push('3') // myArray is now ["1", "2", "3"]{{jsxref("Array.pop", "pop()")}} removes the last element from an array and returns that element.
-let myArray = new Array('1', '2', '3') +let myArray = new Array('1', '2', '3') let last = myArray.pop() // myArray is now ["1", "2"], last = "3"{{jsxref("Array.shift", "shift()")}} removes the first element from an array and returns that element.
-let myArray = new Array('1', '2', '3') +let myArray = new Array('1', '2', '3') let first = myArray.shift() // myArray is now ["2", "3"], first is "1"{{jsxref("Array.unshift", "unshift()")}} adds one or more elements to the front of an array and returns the new length of the array.
-let myArray = new Array('1', '2', '3') +let myArray = new Array('1', '2', '3') myArray.unshift('4', '5') // myArray becomes ["4", "5", "1", "2", "3"]{{jsxref("Array.slice", "slice(start_index, upto_index)")}} extracts a section of an array and returns a new array.
-let myArray = new Array('a', 'b', 'c', 'd', 'e') +let myArray = new Array('a', 'b', 'c', 'd', 'e') myArray = myArray.slice(1, 4) // starts at index 1 and extracts all elements // until index 3, returning [ "b", "c", "d"]{{jsxref("Array.splice", "splice(index, count_to_remove, addElement1, addElement2, ...)")}} removes elements from an array and (optionally) replaces them. It returns the items which were removed from the array.
-let myArray = new Array('1', '2', '3', '4', '5') +let myArray = new Array('1', '2', '3', '4', '5') myArray.splice(1, 3, 'a', 'b', 'c', 'd') // myArray is now ["1", "a", "b", "c", "d", "5"] // This code started at index one (or where the "2" was), @@ -290,14 +290,14 @@Array methods
{{jsxref("Array.reverse", "reverse()")}} transposes the elements of an array, in place: the first array element becomes the last and the last becomes the first. It returns a reference to the array.
-let myArray = new Array('1', '2', '3') +let myArray = new Array('1', '2', '3') myArray.reverse() // transposes the array so that myArray = ["3", "2", "1"]{{jsxref("Array.sort", "sort()")}} sorts the elements of an array in place, and returns a reference to the array.
-let myArray = new Array('Wind', 'Rain', 'Fire') +let myArray = new Array('Wind', 'Rain', 'Fire') myArray.sort() // sorts the array so that myArray = ["Fire", "Rain", "Wind"]@@ -312,7 +312,7 @@Array methods
For instance, the following will sort by the last letter of a string:
-let sortFn = function(a, b) { +let sortFn = function(a, b) { if (a[a.length - 1] < b[b.length - 1]) return -1; if (a[a.length - 1] > b[b.length - 1]) return 1; if (a[a.length - 1] == b[b.length - 1]) return 0; @@ -328,7 +328,7 @@Array methods
{{jsxref("Array.indexOf", "indexOf(searchElement[, fromIndex])")}} searches the array for
-searchElement
and returns the index of the first match.let a = ['a', 'b', 'a', 'b', 'a'] +let a = ['a', 'b', 'a', 'b', 'a'] console.log(a.indexOf('b')) // logs 1 // Now try again, starting from after the last match @@ -338,7 +338,7 @@Array methods
{{jsxref("Array.lastIndexOf", "lastIndexOf(searchElement[, fromIndex])")}} works like
-indexOf
, but starts at the end and searches backwards.let a = ['a', 'b', 'c', 'd', 'a', 'b'] +let a = ['a', 'b', 'c', 'd', 'a', 'b'] console.log(a.lastIndexOf('b')) // logs 5 // Now try again, starting from before the last match @@ -348,28 +348,28 @@Array methods
{{jsxref("Array.forEach", "forEach(callback[, thisObject])")}} executes
-callback
on every array item and returnsundefined
.let a = ['a', 'b', 'c'] +let a = ['a', 'b', 'c'] a.forEach(function(element) { console.log(element) }) // logs each item in turn{{jsxref("Array.map", "map(callback[, thisObject])")}} returns a new array of the return value from executing
-callback
on every array item.let a1 = ['a', 'b', 'c'] +let a1 = ['a', 'b', 'c'] let a2 = a1.map(function(item) { return item.toUpperCase() }) console.log(a2) // logs ['A', 'B', 'C']{{jsxref("Array.filter", "filter(callback[, thisObject])")}} returns a new array containing the items for which
-callback
returnedtrue
.let a1 = ['a', 10, 'b', 20, 'c', 30] +let a1 = ['a', 10, 'b', 20, 'c', 30] let a2 = a1.filter(function(item) { return typeof item === 'number'; }) console.log(a2) // logs [10, 20, 30]{{jsxref("Array.every", "every(callback[, thisObject])")}} returns
-true
ifcallback
returnstrue
for every item in the array.function isNumber(value) { +function isNumber(value) { return typeof value === 'number' } let a1 = [1, 2, 3] @@ -380,7 +380,7 @@Array methods
{{jsxref("Array.some", "some(callback[, thisObject])")}} returns
-true
ifcallback
returnstrue
for at least one item in the array.function isNumber(value) { +function isNumber(value) { return typeof value === 'number' } let a1 = [1, 2, 3] @@ -399,7 +399,7 @@Array methods
If
-callback
needs access to the index of the item being processed, on access to the entire array, they are available as optional parameters.let a = [10, 20, 30] +let a = [10, 20, 30] let total = a.reduce(function(accumulator, currentValue) { return accumulator + currentValue }, 0) console.log(total) // Prints 60@@ -414,7 +414,7 @@Multi-dimensional arrays
The following code creates a two-dimensional array.
-let a = new Array(4) +let a = new Array(4) for (let i = 0; i < 4; i++) { a[i] = new Array(4) for (let j = 0; j < 4; j++) { @@ -425,7 +425,7 @@Multi-dimensional arrays
This example creates an array with the following rows:
-Row 0: [0, 0] [0, 1] [0, 2] [0, 3] +Row 0: [0, 0] [0, 1] [0, 2] [0, 3] Row 1: [1, 0] [1, 1] [1, 2] [1, 3] Row 2: [2, 0] [2, 1] [2, 2] [2, 3] Row 3: [3, 0] [3, 1] [3, 2] [3, 3] @@ -435,7 +435,7 @@Using arrays to store other prop
Arrays can also be used like objects, to store related information.
-const arr = [1, 2, 3]; +
@@ -450,7 +450,7 @@const arr = [1, 2, 3]; arr.property = "value"; console.log(arr.property); // Logs "value"
Working with array-like objects
Array methods cannot be called directly on array-like objects.
-function printArguments() { +
function printArguments() { arguments.forEach(function(item) { //
console.log(item); }); @@ -459,7 +459,7 @@Working with array-like objects
But you can call them indirectly using {{jsxref("Global_Objects/Function/call","Function.prototype.call()")}}.
-function printArguments() { +
function printArguments() { Array.prototype.forEach.call(arguments, function(item) { console.log(item); }); @@ -468,7 +468,7 @@
Working with array-like objects
Array prototype methods can be used on strings as well, since they provide sequential access to their characters in a similar way to arrays:
-Array.prototype.forEach.call('a string', function(chr) { +Array.prototype.forEach.call('a string', function(chr) { console.log(chr) })diff --git a/files/en-us/web/javascript/guide/introduction/index.html b/files/en-us/web/javascript/guide/introduction/index.html index d84781015290e83..438eec7cee90882 100644 --- a/files/en-us/web/javascript/guide/introduction/index.html +++ b/files/en-us/web/javascript/guide/introduction/index.html @@ -119,7 +119,7 @@Single-line input in the Web Conso
The console works the exact same way as
-eval
: the last expression entered is returned. For the sake of simplicity, it can be imagined that every time something is entered into the console, it is actually surrounded byconsole.log
aroundeval
, like so:function greetMe(yourName) { +function greetMe(yourName) { alert("Hello " + yourName) }console.log(eval('3 + 5'))
@@ -133,7 +133,7 @@Hello world
To get started with writing JavaScript, open the Web Console in multi-line mode, and write your first "Hello world" JavaScript code:
-(function(){ +(function(){ "use strict"; /* Start of your code */ function greetMe(yourName) { diff --git a/files/en-us/web/javascript/guide/iterators_and_generators/index.html b/files/en-us/web/javascript/guide/iterators_and_generators/index.html index 0c03825983c5afc..c465f20cefc1686 100644 --- a/files/en-us/web/javascript/guide/iterators_and_generators/index.html +++ b/files/en-us/web/javascript/guide/iterators_and_generators/index.html @@ -43,7 +43,7 @@Iterators
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) toend
(exclusive) spacedstep
apart. Its final return value is the size of the sequence it created, tracked by the variableiterationCount
.function makeRangeIterator(start = 0, end = Infinity, step = 1) { +function makeRangeIterator(start = 0, end = Infinity, step = 1) { let nextIndex = start; let iterationCount = 0; @@ -65,7 +65,7 @@Iterators
Using the iterator then looks like this:
-const it = makeRangeIterator(1, 10, 2); +const it = makeRangeIterator(1, 10, 2); let result = it.next(); while (!result.done) { @@ -91,7 +91,7 @@