Basics Flashcards
declare a variable
let varrr = 123;
local scope variable
let tmp = “test”;
global scope variable
var tmp = “test”;
constant variable
const tmp = “3.1411414”
declare a table
let tab = []; or let tab = Array();
what is the function that adds a new element to the end of an array
.push(element);
what is the function that adds a new element to the start of an array
.unshift(element);
what is the function that adds one or multiple elements to some position in the array
.splice(<start>, <delete>, <element1>, <element2>....);</element2></element1></delete></start>
what function removes one or multiple elements from some position in an array and return the deleted values in a list
.splice(<start>, <delete>);</delete></start>
what function removes the last element from a list
.pop()
what function removes the first element in a list
.shift()
how to access an element in a list
by it’s index
what is the function that gets all element with the same class name
document.getElementById(<”id”>)
what is the function that gets all elements with the same tag name
document.getElementsByTagName(<”tag name”>)
what is the function that gets an element with a unique id
document.getElementById(<”id”>);
what is the function that gets the first child node of an element
<element>.firstChild();
</element>
what is the function that gets the first child element of an element
<element>.firstElementChild();
</element>
what is the function that gets you the next sibling node of an element
<element>.nextSibling()
</element>
what is the function that gets you the previous sibling node of an element
<element>.previousSibling()
</element>