data & then some');
docu.getElementsByTagName('xml')[0].appendChild(cdata);
diff --git a/files/en-us/web/api/document/createcomment/index.md b/files/en-us/web/api/document/createcomment/index.md
index 7025078d6761c87..cad266eb32341cc 100644
--- a/files/en-us/web/api/document/createcomment/index.md
+++ b/files/en-us/web/api/document/createcomment/index.md
@@ -32,8 +32,8 @@ A new {{domxref("Comment")}} object.
## Examples
```js
-var docu = new DOMParser().parseFromString('', 'application/xml');
-var comment = docu.createComment('This is a not-so-secret comment in your document');
+const docu = new DOMParser().parseFromString('', 'application/xml');
+const comment = docu.createComment('This is a not-so-secret comment in your document');
docu.getElementsByTagName('xml')[0].appendChild(comment);
diff --git a/files/en-us/web/api/document/createevent/index.md b/files/en-us/web/api/document/createevent/index.md
index 10bd0a4fe7871e0..fde4016ec87cbba 100644
--- a/files/en-us/web/api/document/createevent/index.md
+++ b/files/en-us/web/api/document/createevent/index.md
@@ -37,7 +37,7 @@ An [Event](/en-US/docs/Web/API/Event) object.
```js
// Create the event.
-var event = document.createEvent('Event');
+const event = document.createEvent('Event');
// Define that the event name is 'build'.
event.initEvent('build', true, true);
diff --git a/files/en-us/web/api/document/createprocessinginstruction/index.md b/files/en-us/web/api/document/createprocessinginstruction/index.md
index bffda297e12e88d..e8dc9b25b6fdade 100644
--- a/files/en-us/web/api/document/createprocessinginstruction/index.md
+++ b/files/en-us/web/api/document/createprocessinginstruction/index.md
@@ -45,8 +45,8 @@ None ({{jsxref("undefined")}}).
## Examples
```js
-var doc = new DOMParser().parseFromString('', 'application/xml');
-var pi = doc.createProcessingInstruction('xml-stylesheet', 'href="mycss.css" type="text/css"');
+const doc = new DOMParser().parseFromString('', 'application/xml');
+const pi = doc.createProcessingInstruction('xml-stylesheet', 'href="mycss.css" type="text/css"');
doc.insertBefore(pi, doc.firstChild);
diff --git a/files/en-us/web/api/document/createtouch/index.md b/files/en-us/web/api/document/createtouch/index.md
index ab401ea8bf9c5ff..50182437f071135 100644
--- a/files/en-us/web/api/document/createtouch/index.md
+++ b/files/en-us/web/api/document/createtouch/index.md
@@ -76,10 +76,10 @@ In following code snippet, two {{DOMxRef("Touch")}} objects are created for the
`target` element.
```js
-var target = document.getElementById("target");
+const target = document.getElementById("target");
-var touch1 = document.createTouch(window, target, 1, 15, 20, 35, 40);
-var touch2 = document.createTouch(window, target, 2, 25, 30, 45, 50);
+const touch1 = document.createTouch(window, target, 1, 15, 20, 35, 40);
+const touch2 = document.createTouch(window, target, 2, 25, 30, 45, 50);
```
## Specifications
diff --git a/files/en-us/web/api/document/createtouchlist/index.md b/files/en-us/web/api/document/createtouchlist/index.md
index 4b9573267178580..b72f72b57371aab 100644
--- a/files/en-us/web/api/document/createtouchlist/index.md
+++ b/files/en-us/web/api/document/createtouchlist/index.md
@@ -48,20 +48,20 @@ In following code snippet, some {{DOMxRef("Touch")}} objects are created for the
{{DOMxRef("TouchList")}} objects.
```js
-var target = document.getElementById("target");
+const target = document.getElementById("target");
// Create some touch points
-var touch1 = document.createTouch(window, target, 1, 15, 20, 35, 40);
-var touch2 = document.createTouch(window, target, 2, 25, 30, 45, 50);
+const touch1 = document.createTouch(window, target, 1, 15, 20, 35, 40);
+const touch2 = document.createTouch(window, target, 2, 25, 30, 45, 50);
// Create an empty TouchList objects
-var list0 = document.createTouchList();
+const list0 = document.createTouchList();
// Create a TouchList with only one Touch object
-var list1 = document.createTouchList(touch1);
+const list1 = document.createTouchList(touch1);
// Create a list with two Touch objects
-var list2 = document.createTouchList(touch1, touch2);
+const list2 = document.createTouchList(touch1, touch2);
```
## Specifications
diff --git a/files/en-us/web/api/document/createtreewalker/index.md b/files/en-us/web/api/document/createtreewalker/index.md
index ba70f4e1f9ff7f6..3ee73489f42e071 100644
--- a/files/en-us/web/api/document/createtreewalker/index.md
+++ b/files/en-us/web/api/document/createtreewalker/index.md
@@ -71,14 +71,14 @@ that is created to advance through the nodes (now all elements) and push them in
array.
```js
-var treeWalker = document.createTreeWalker(
+const treeWalker = document.createTreeWalker(
document.body,
NodeFilter.SHOW_ELEMENT,
{ acceptNode(node) { return NodeFilter.FILTER_ACCEPT; } }
);
-var nodeList = [];
-var currentNode = treeWalker.currentNode;
+const nodeList = [];
+let currentNode = treeWalker.currentNode;
while(currentNode) {
nodeList.push(currentNode);
diff --git a/files/en-us/web/api/document/doctype/index.md b/files/en-us/web/api/document/doctype/index.md
index 7dbe7f06e28d92a..ba10a6881975abb 100644
--- a/files/en-us/web/api/document/doctype/index.md
+++ b/files/en-us/web/api/document/doctype/index.md
@@ -26,7 +26,7 @@ A {{domxref("DocumentType")}} object.
## Examples
```js
-var doctypeObj = document.doctype;
+const doctypeObj = document.doctype;
console.log(`doctypeObj.name: ${doctypeObj.name}`);
console.log(`doctypeObj.internalSubset: ${doctypeObj.internalSubset}`);
diff --git a/files/en-us/web/api/document/elementsfrompoint/index.md b/files/en-us/web/api/document/elementsfrompoint/index.md
index 84fca163e2cbc3f..a0ff8035e6c5a83 100644
--- a/files/en-us/web/api/document/elementsfrompoint/index.md
+++ b/files/en-us/web/api/document/elementsfrompoint/index.md
@@ -55,7 +55,7 @@ An array of {{domxref('Element')}} objects, ordered from the topmost to the bott
let output = document.getElementById("output");
if (document.elementsFromPoint) {
let elements = document.elementsFromPoint(30, 20);
- for (var i = 0; i < elements.length; i++) {
+ for (let i = 0; i < elements.length; i++) {
output.textContent += elements[i].localName;
if (i < elements.length - 1) {
output.textContent += " < ";
diff --git a/files/en-us/web/api/document/evaluate/index.md b/files/en-us/web/api/document/evaluate/index.md
index 153d92128312e6c..df49d76c409543b 100644
--- a/files/en-us/web/api/document/evaluate/index.md
+++ b/files/en-us/web/api/document/evaluate/index.md
@@ -99,11 +99,11 @@ if not, it is the same object as the one passed as the `result` parameter.
## Examples
```js
-var headings = document.evaluate("/html/body//h2", document, null, XPathResult.ANY_TYPE, null);
+const headings = document.evaluate("/html/body//h2", document, null, XPathResult.ANY_TYPE, null);
/* Search the document for all h2 elements.
* The result will likely be an unordered node iterator. */
-var thisHeading = headings.iterateNext();
-var alertText = "Level 2 headings in this document are:\n";
+let thisHeading = headings.iterateNext();
+let alertText = "Level 2 headings in this document are:\n";
while (thisHeading) {
alertText += `${thisHeading.textContent}\n`;
thisHeading = headings.iterateNext();
diff --git a/files/en-us/web/api/document/getelementsbyname/index.md b/files/en-us/web/api/document/getelementsbyname/index.md
index 106c9e1be674ed0..0f0c14252601b6f 100644
--- a/files/en-us/web/api/document/getelementsbyname/index.md
+++ b/files/en-us/web/api/document/getelementsbyname/index.md
@@ -48,7 +48,7 @@ A live {{domxref("NodeList")}} collection, meaning it automatically updates as n
```
```js
-var up_names = document.getElementsByName("up");
+const up_names = document.getElementsByName("up");
console.log(up_names[0].tagName); // displays "INPUT"
```
diff --git a/files/en-us/web/api/document/images/index.md b/files/en-us/web/api/document/images/index.md
index 7a174b888c0d9c8..aee7557b89d2e3c 100644
--- a/files/en-us/web/api/document/images/index.md
+++ b/files/en-us/web/api/document/images/index.md
@@ -40,9 +40,9 @@ This example looks through the list of images and finds one whose name is
`"banner.gif"`.
```js
-var ilist = document.images;
+const ilist = document.images;
-for(var i = 0; i < ilist.length; i++) {
+for(let i = 0; i < ilist.length; i++) {
if(ilist[i].src === 'banner.gif') {
// found the banner
}
diff --git a/files/en-us/web/api/document/lastmodified/index.md b/files/en-us/web/api/document/lastmodified/index.md
index 09833410b4a715c..12d146b54c2af98 100644
--- a/files/en-us/web/api/document/lastmodified/index.md
+++ b/files/en-us/web/api/document/lastmodified/index.md
@@ -65,14 +65,13 @@ if (Date.parse(document.lastModified) > parseFloat(document.cookie.replace(/(?:(
…the same example, but skipping the first visit:
```js
-var
- nLastVisit = parseFloat(document.cookie.replace(/(?:(?:^|.*;)\s*last_modif\s*\=\s*([^;]*).*$)|^.*$/, "$1")),
- nLastModif = Date.parse(document.lastModified);
+const lastVisit = parseFloat(document.cookie.replace(/(?:(?:^|.*;)\s*last_modif\s*\=\s*([^;]*).*$)|^.*$/, "$1"));
+const lastModif = Date.parse(document.lastModified);
-if (isNaN(nLastVisit) || nLastModif > nLastVisit) {
+if (isNaN(lastVisit) || lastModif > lastVisit) {
document.cookie = `last_modif=${Date.now()}; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=${location.pathname}`;
- if (isFinite(nLastVisit)) {
+ if (isFinite(lastVisit)) {
alert("This page has been changed!");
}
}
diff --git a/files/en-us/web/api/document/mozsyntheticdocument/index.md b/files/en-us/web/api/document/mozsyntheticdocument/index.md
index 079e3e3f457676c..d43b33619850efd 100644
--- a/files/en-us/web/api/document/mozsyntheticdocument/index.md
+++ b/files/en-us/web/api/document/mozsyntheticdocument/index.md
@@ -26,7 +26,7 @@ This can be useful if you have a contextual menu item you only want to display f
synthetic documents (or, conversely, for documents that aren't synthetic).
```js
-var isSynthetic = document.mozSyntheticDocument;
+const isSynthetic = document.mozSyntheticDocument;
if (isSynthetic) {
/* insert your menu item here */
diff --git a/files/en-us/web/api/document/msthumbnailclick_event/index.md b/files/en-us/web/api/document/msthumbnailclick_event/index.md
index 910de6e7a955796..e0e94faf2b5e3bb 100644
--- a/files/en-us/web/api/document/msthumbnailclick_event/index.md
+++ b/files/en-us/web/api/document/msthumbnailclick_event/index.md
@@ -66,7 +66,7 @@ window.external.msSiteModeClearIconOverlay();
handlerdocument.addEventListener('msthumbnailclick', onButtonClicked, false);
// add the buttons
-var btnPlay = window.external.msSiteModeAddThumbBarButton(iconUri, toolTip);
+const btnPlay = window.external.msSiteModeAddThumbBarButton(iconUri, toolTip);
// refresh the taskbar
window.external.msSiteModeShowThumbBar();
diff --git a/files/en-us/web/api/document/querycommandenabled/index.md b/files/en-us/web/api/document/querycommandenabled/index.md
index ec739c8701b3ded..0cfb995175e1178 100644
--- a/files/en-us/web/api/document/querycommandenabled/index.md
+++ b/files/en-us/web/api/document/querycommandenabled/index.md
@@ -42,7 +42,7 @@ and `false` if the command isn't`.`
## Example
```js
-var flg = document.queryCommandEnabled("SelectAll");
+const flg = document.queryCommandEnabled("SelectAll");
if(flg) {
document.execCommand("SelectAll", false, null); // command is enabled, run it
diff --git a/files/en-us/web/api/document/querycommandsupported/index.md b/files/en-us/web/api/document/querycommandsupported/index.md
index e98c1f4fa6ff743..bbaa05238274a35 100644
--- a/files/en-us/web/api/document/querycommandsupported/index.md
+++ b/files/en-us/web/api/document/querycommandsupported/index.md
@@ -42,7 +42,7 @@ the action.
## Examples
```js
-var flg = document.queryCommandSupported("SelectAll");
+const flg = document.queryCommandSupported("SelectAll");
if(flg) {
// Do something…
diff --git a/files/en-us/web/api/document/queryselector/index.md b/files/en-us/web/api/document/queryselector/index.md
index 429db6341dbb23c..d9b795077001c53 100644
--- a/files/en-us/web/api/document/queryselector/index.md
+++ b/files/en-us/web/api/document/queryselector/index.md
@@ -97,7 +97,7 @@ In this example, the first element in the document with the class
"`myclass`" is returned:
```js
-var el = document.querySelector(".myclass");
+const el = document.querySelector(".myclass");
```
### Complex selectors
@@ -109,7 +109,7 @@ class is "user-panel main" (``) in the
document is returned:
```js
-var el = document.querySelector("div.user-panel.main input[name='login']");
+const el = document.querySelector("div.user-panel.main input[name='login']");
```
### Negation
@@ -117,7 +117,7 @@ var el = document.querySelector("div.user-panel.main input[name='login']");
As all CSS selector strings are valid, you can also negate selectors:
```js
-var el = document.querySelector("div.user-panel:not(.main) input[name='login']");
+const el = document.querySelector("div.user-panel:not(.main) input[name='login']");
```
This will select an input with a parent div with the `user-panel` class but
diff --git a/files/en-us/web/api/document/registerelement/index.md b/files/en-us/web/api/document/registerelement/index.md
index eb5a58c863f7714..6f4f54c388e368a 100644
--- a/files/en-us/web/api/document/registerelement/index.md
+++ b/files/en-us/web/api/document/registerelement/index.md
@@ -47,7 +47,7 @@ None ({{jsxref("undefined")}}).
Here is a very simple example:
```js
-var Mytag = document.registerElement('my-tag');
+const Mytag = document.registerElement('my-tag');
```
Now the new tag is registered in the browser. The `Mytag` variable holds a
@@ -64,7 +64,7 @@ capability. And it won't be visible in the browser unless you add some content t
tag. Here is one way to add content to the new tag:
```js
-var mytag = document.getElementsByTagName("my-tag")[0];
+const mytag = document.getElementsByTagName("my-tag")[0];
mytag.textContent = "I am a my-tag element.";
```
diff --git a/files/en-us/web/api/document/scrollingelement/index.md b/files/en-us/web/api/document/scrollingelement/index.md
index c292a0bdb094b1e..48791f52744b16a 100644
--- a/files/en-us/web/api/document/scrollingelement/index.md
+++ b/files/en-us/web/api/document/scrollingelement/index.md
@@ -27,7 +27,7 @@ The {{domxref("Element")}} that scrolls the document, usually the root element (
## Examples
```js
-var scrollElm = document.scrollingElement;
+const scrollElm = document.scrollingElement;
scrollElm.scrollTop = 0;
```
diff --git a/files/en-us/web/api/document_object_model/how_to_create_a_dom_tree/index.md b/files/en-us/web/api/document_object_model/how_to_create_a_dom_tree/index.md
index 0e4aee8b9ecd345..d2a63456f7e5463 100644
--- a/files/en-us/web/api/document_object_model/how_to_create_a_dom_tree/index.md
+++ b/files/en-us/web/api/document_object_model/how_to_create_a_dom_tree/index.md
@@ -38,47 +38,47 @@ Consider the following XML document:
The W3C DOM API, supported by Mozilla, can be used to create an in-memory representation of this document like so:
```js
-var doc = document.implementation.createDocument("", "", null);
-var peopleElem = doc.createElement("people");
+const doc = document.implementation.createDocument("", "", null);
+const peopleElem = doc.createElement("people");
-var personElem1 = doc.createElement("person");
+const personElem1 = doc.createElement("person");
personElem1.setAttribute("first-name", "eric");
personElem1.setAttribute("middle-initial", "h");
personElem1.setAttribute("last-name", "jung");
-var addressElem1 = doc.createElement("address");
+const addressElem1 = doc.createElement("address");
addressElem1.setAttribute("street", "321 south st");
addressElem1.setAttribute("city", "denver");
addressElem1.setAttribute("state", "co");
addressElem1.setAttribute("country", "usa");
personElem1.appendChild(addressElem1);
-var addressElem2 = doc.createElement("address");
+const addressElem2 = doc.createElement("address");
addressElem2.setAttribute("street", "123 main st");
addressElem2.setAttribute("city", "arlington");
addressElem2.setAttribute("state", "ma");
addressElem2.setAttribute("country", "usa");
personElem1.appendChild(addressElem2);
-var personElem2 = doc.createElement("person");
+const personElem2 = doc.createElement("person");
personElem2.setAttribute("first-name", "jed");
personElem2.setAttribute("last-name", "brown");
-var addressElem3 = doc.createElement("address");
+const addressElem3 = doc.createElement("address");
addressElem3.setAttribute("street", "321 north st");
addressElem3.setAttribute("city", "atlanta");
addressElem3.setAttribute("state", "ga");
addressElem3.setAttribute("country", "usa");
personElem2.appendChild(addressElem3);
-var addressElem4 = doc.createElement("address");
+const addressElem4 = doc.createElement("address");
addressElem4.setAttribute("street", "123 west st");
addressElem4.setAttribute("city", "seattle");
addressElem4.setAttribute("state", "wa");
addressElem4.setAttribute("country", "usa");
personElem2.appendChild(addressElem4);
-var addressElem5 = doc.createElement("address");
+const addressElem5 = doc.createElement("address");
addressElem5.setAttribute("street", "321 south avenue");
addressElem5.setAttribute("city", "denver");
addressElem5.setAttribute("state", "co");
diff --git a/files/en-us/web/api/domimplementation/createdocumenttype/index.md b/files/en-us/web/api/domimplementation/createdocumenttype/index.md
index 4ddbc4b76442bdb..beaa9cb0edb2cd2 100644
--- a/files/en-us/web/api/domimplementation/createdocumenttype/index.md
+++ b/files/en-us/web/api/domimplementation/createdocumenttype/index.md
@@ -41,8 +41,8 @@ None ({{jsxref("undefined")}}).
## Examples
```js
-var dt = document.implementation.createDocumentType('svg:svg', '-//W3C//DTD SVG 1.1//EN', 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
-var d = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg:svg', dt);
+const dt = document.implementation.createDocumentType('svg:svg', '-//W3C//DTD SVG 1.1//EN', 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
+const d = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg:svg', dt);
alert(d.doctype.publicId); // -//W3C//DTD SVG 1.1//EN
```
diff --git a/files/en-us/web/api/dommatrix/dommatrix/index.md b/files/en-us/web/api/dommatrix/dommatrix/index.md
index 89d8227302c3ab3..fb455d139b499fe 100644
--- a/files/en-us/web/api/dommatrix/dommatrix/index.md
+++ b/files/en-us/web/api/dommatrix/dommatrix/index.md
@@ -40,13 +40,13 @@ This example creates a DOMMatrix to use as an argument for calling
{{domxref("Point.matrixTransform()")}}.
```js
-var point = new DOMPoint(5, 4);
-var scaleX = 2;
-var scaleY = 3;
-var translateX = 12;
-var translateY = 8;
-var angle = Math.PI / 2;
-var matrix = new DOMMatrix([
+const point = new DOMPoint(5, 4);
+const scaleX = 2;
+const scaleY = 3;
+const translateX = 12;
+const translateY = 8;
+const angle = Math.PI / 2;
+const matrix = new DOMMatrix([
Math.sin(angle) * scaleX,
Math.cos(angle) * scaleX,
-Math.sin(angle) * scaleY,
@@ -54,7 +54,7 @@ var matrix = new DOMMatrix([
translateX,
translateY
]);
-var transformedPoint = point.matrixTransform(matrix);
+const transformedPoint = point.matrixTransform(matrix);
```
## Specifications
diff --git a/files/en-us/web/api/dompoint/dompoint/index.md b/files/en-us/web/api/dompoint/dompoint/index.md
index e86b7f8c8f90644..a68ba2ded38e231 100644
--- a/files/en-us/web/api/dompoint/dompoint/index.md
+++ b/files/en-us/web/api/dompoint/dompoint/index.md
@@ -52,8 +52,8 @@ current window, then creates a second point based on the first, which is then of
100 pixels both vertically and horizontally.
```js
-var windTopLeft = new DOMPoint(window.screenX, window.screenY);
-var newTopLeft = DOMPoint.fromPoint(windTopLeft);
+const windTopLeft = new DOMPoint(window.screenX, window.screenY);
+const newTopLeft = DOMPoint.fromPoint(windTopLeft);
newTopLeft.x += 100;
newTopLeft.y += 100;
```
diff --git a/files/en-us/web/api/dompoint/frompoint/index.md b/files/en-us/web/api/dompoint/frompoint/index.md
index 7a61c98abea16d7..748f061fb7def4f 100644
--- a/files/en-us/web/api/dompoint/frompoint/index.md
+++ b/files/en-us/web/api/dompoint/frompoint/index.md
@@ -65,7 +65,7 @@ If you have a {{domxref("DOMPointReadOnly")}} object, you can easily create a mu
copy of that point:
```js
-var mutablePoint = DOMPoint.fromPoint(readOnlyPoint);
+const mutablePoint = DOMPoint.fromPoint(readOnlyPoint);
```
### Creating a 2D point
@@ -76,7 +76,7 @@ use for {{domxref("DOMPointReadOnly.x", "x")}} and {{domxref("DOMPointReadOnly.y
values (0 and 1 respectively).
```js
-var center = DOMPoint.fromPoint({x: 75, y: -50, z: -55, w: 0.25});
+const center = DOMPoint.fromPoint({x: 75, y: -50, z: -55, w: 0.25});
```
## Specifications
diff --git a/files/en-us/web/api/dompointreadonly/dompointreadonly/index.md b/files/en-us/web/api/dompointreadonly/dompointreadonly/index.md
index 13f925f639dd80d..d341d3a8d4a1299 100644
--- a/files/en-us/web/api/dompointreadonly/dompointreadonly/index.md
+++ b/files/en-us/web/api/dompointreadonly/dompointreadonly/index.md
@@ -60,9 +60,9 @@ space.
The following code demonstrates creating both 2D and 3D points.
```js
-var point2D = new DOMPointReadOnly(50, 25);
-var point3D = new DOMPointReadOnly(50, 0, 10);
-var perspectivePoint3D = new DOMPointReadOnly(50, 50, 25, 0.5);
+const point2D = new DOMPointReadOnly(50, 25);
+const point3D = new DOMPointReadOnly(50, 0, 10);
+const perspectivePoint3D = new DOMPointReadOnly(50, 50, 25, 0.5);
```
## Specifications
diff --git a/files/en-us/web/api/dompointreadonly/tojson/index.md b/files/en-us/web/api/dompointreadonly/tojson/index.md
index e73b58a2be2b3bf..3a4e58e53fa86c3 100644
--- a/files/en-us/web/api/dompointreadonly/tojson/index.md
+++ b/files/en-us/web/api/dompointreadonly/tojson/index.md
@@ -43,9 +43,9 @@ This example creates a {{domxref("DOMPoint")}} object representing the top-left
of the current window, in screen coordinates, then converts that to JSON.
```js
-var topLeft = new DOMPoint(window.screenX, window.screenY);
+const topLeft = new DOMPoint(window.screenX, window.screenY);
-var pointJSON = topLeft.toJSON();
+const pointJSON = topLeft.toJSON();
```
## Specifications
diff --git a/files/en-us/web/api/dynamicscompressornode/attack/index.md b/files/en-us/web/api/dynamicscompressornode/attack/index.md
index 11aa7368e8a2214..633e71a8c8f79d9 100644
--- a/files/en-us/web/api/dynamicscompressornode/attack/index.md
+++ b/files/en-us/web/api/dynamicscompressornode/attack/index.md
@@ -26,8 +26,8 @@ An {{domxref("AudioParam")}}.
## Examples
```js
-var audioCtx = new AudioContext();
-var compressor = audioCtx.createDynamicsCompressor();
+const audioCtx = new AudioContext();
+const compressor = audioCtx.createDynamicsCompressor();
compressor.attack.value = 0;
```
diff --git a/files/en-us/web/api/dynamicscompressornode/knee/index.md b/files/en-us/web/api/dynamicscompressornode/knee/index.md
index b84b2eaacac673b..562a0427f275e06 100644
--- a/files/en-us/web/api/dynamicscompressornode/knee/index.md
+++ b/files/en-us/web/api/dynamicscompressornode/knee/index.md
@@ -28,8 +28,8 @@ An {{domxref("AudioParam")}}.
## Examples
```js
-var audioCtx = new AudioContext();
-var compressor = audioCtx.createDynamicsCompressor();
+const audioCtx = new AudioContext();
+const compressor = audioCtx.createDynamicsCompressor();
compressor.knee.value = 40;
```
diff --git a/files/en-us/web/api/dynamicscompressornode/ratio/index.md b/files/en-us/web/api/dynamicscompressornode/ratio/index.md
index 98c16ac1548ff5d..72196090352392d 100644
--- a/files/en-us/web/api/dynamicscompressornode/ratio/index.md
+++ b/files/en-us/web/api/dynamicscompressornode/ratio/index.md
@@ -28,8 +28,8 @@ An {{domxref("AudioParam")}}.
## Examples
```js
-var audioCtx = new AudioContext();
-var compressor = audioCtx.createDynamicsCompressor();
+const audioCtx = new AudioContext();
+const compressor = audioCtx.createDynamicsCompressor();
compressor.ratio.value = 12;
```
diff --git a/files/en-us/web/api/dynamicscompressornode/reduction/index.md b/files/en-us/web/api/dynamicscompressornode/reduction/index.md
index 8ff95be35c313d7..0b0bc980fb952fd 100644
--- a/files/en-us/web/api/dynamicscompressornode/reduction/index.md
+++ b/files/en-us/web/api/dynamicscompressornode/reduction/index.md
@@ -24,9 +24,9 @@ A float.
## Examples
```js
-var audioCtx = new AudioContext();
-var compressor = audioCtx.createDynamicsCompressor();
-var myReduction = compressor.reduction;
+const audioCtx = new AudioContext();
+const compressor = audioCtx.createDynamicsCompressor();
+const myReduction = compressor.reduction;
```
See [`BaseAudioContext.createDynamicsCompressor()`](/en-US/docs/Web/API/BaseAudioContext/createDynamicsCompressor#example) for more complete example code.
diff --git a/files/en-us/web/api/dynamicscompressornode/release/index.md b/files/en-us/web/api/dynamicscompressornode/release/index.md
index 94847740bb1571f..0318f01f338516d 100644
--- a/files/en-us/web/api/dynamicscompressornode/release/index.md
+++ b/files/en-us/web/api/dynamicscompressornode/release/index.md
@@ -26,8 +26,8 @@ An {{domxref("AudioParam")}}.
## Examples
```js
-var audioCtx = new AudioContext();
-var compressor = audioCtx.createDynamicsCompressor();
+const audioCtx = new AudioContext();
+const compressor = audioCtx.createDynamicsCompressor();
compressor.release.value = 0.25;
```
diff --git a/files/en-us/web/api/dynamicscompressornode/threshold/index.md b/files/en-us/web/api/dynamicscompressornode/threshold/index.md
index c0bb45b43e449dc..66af10b1ab42e43 100644
--- a/files/en-us/web/api/dynamicscompressornode/threshold/index.md
+++ b/files/en-us/web/api/dynamicscompressornode/threshold/index.md
@@ -28,8 +28,8 @@ An {{domxref("AudioParam")}}.
## Examples
```js
-var audioCtx = new AudioContext();
-var compressor = audioCtx.createDynamicsCompressor();
+const audioCtx = new AudioContext();
+const compressor = audioCtx.createDynamicsCompressor();
compressor.threshold.value = -50;
```
diff --git a/files/en-us/web/api/element/fullscreenchange_event/index.md b/files/en-us/web/api/element/fullscreenchange_event/index.md
index 49cbfa254c46f80..95d4c91ba470091 100644
--- a/files/en-us/web/api/element/fullscreenchange_event/index.md
+++ b/files/en-us/web/api/element/fullscreenchange_event/index.md
@@ -68,7 +68,7 @@ function fullscreenchanged(event) {
}
};
-var el = document.getElementById('fullscreen-div');
+const el = document.getElementById('fullscreen-div');
el.addEventListener('fullscreenchange', fullscreenchanged);
// or
diff --git a/files/en-us/web/api/element/getboundingclientrect/index.md b/files/en-us/web/api/element/getboundingclientrect/index.md
index ddd63fe0ae947d8..4fef21dd4af245f 100644
--- a/files/en-us/web/api/element/getboundingclientrect/index.md
+++ b/files/en-us/web/api/element/getboundingclientrect/index.md
@@ -107,7 +107,7 @@ div {
```js
let elem = document.querySelector('div');
let rect = elem.getBoundingClientRect();
-for (var key in rect) {
+for (const key in rect) {
if(typeof rect[key] !== 'function') {
let para = document.createElement('p');
para.textContent = `${key} : ${rect[key]}`;
@@ -155,7 +155,7 @@ function update() {
const rect = elem.getBoundingClientRect();
container.innerHTML = '';
- for (let key in rect) {
+ for (const key in rect) {
if(typeof rect[key] !== 'function') {
let para = document.createElement('p');
para.textContent = `${key} : ${rect[key]}`;
diff --git a/files/en-us/web/api/element/getelementsbyclassname/index.md b/files/en-us/web/api/element/getelementsbyclassname/index.md
index c3aedab8df77e58..10b9168769654fd 100644
--- a/files/en-us/web/api/element/getelementsbyclassname/index.md
+++ b/files/en-us/web/api/element/getelementsbyclassname/index.md
@@ -91,9 +91,9 @@ work as one might expect because `"matches"` will change as
soon as any `"colorbox"` class is removed.
```js
-var matches = element.getElementsByClassName('colorbox');
+const matches = element.getElementsByClassName('colorbox');
-for (var i=0; i 0) {
matches.item(0).classList.add('hueframe');
@@ -123,8 +123,8 @@ method's `this` value. Here we'll find all {{HTMLElement("div")}} elements
that have a class of `test`:
```js
-var testElements = document.getElementsByClassName('test');
-var testDivs = Array.prototype.filter.call(testElements, function(testElement) {
+const testElements = document.getElementsByClassName('test');
+const testDivs = Array.prototype.filter.call(testElements, function(testElement) {
return testElement.nodeName === 'DIV';
});
```
diff --git a/files/en-us/web/api/element/hasattribute/index.md b/files/en-us/web/api/element/hasattribute/index.md
index 214d3fef18ede1e..5807020c4258def 100644
--- a/files/en-us/web/api/element/hasattribute/index.md
+++ b/files/en-us/web/api/element/hasattribute/index.md
@@ -34,7 +34,7 @@ A boolean.
## Examples
```js
-var foo = document.getElementById("foo");
+const foo = document.getElementById("foo");
if (foo.hasAttribute("bar")) {
// do something
}
diff --git a/files/en-us/web/api/element/hasattributens/index.md b/files/en-us/web/api/element/hasattributens/index.md
index 363df2d0b17034e..270c73f68213434 100644
--- a/files/en-us/web/api/element/hasattributens/index.md
+++ b/files/en-us/web/api/element/hasattributens/index.md
@@ -33,7 +33,7 @@ A boolean.
```js
// Check that the attribute exists before you set a value
-var d = document.getElementById("div1");
+const d = document.getElementById("div1");
if (d.hasAttributeNS(
"http://www.mozilla.org/ns/specialspace/",
"special-align")) {