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>
what is the function that gets the next element sibling of an element
<element>.nextElementSibling()
</element>
what is the function that gets the previous element sibling of an element
<element>.previousElementSibling()
</element>
what is XMLHttpRequest
a JavaScript object that allows the developer to retrieve data from an endpoint with out reloading a page
how to use $.ajax try to remember the syntax
$.ajax({
url: “target_url”,
type: POST,
data: {username:”test”},
datatype:”json”,
success: (response)=>{
console.log(response);
}
error: (Xhr, status, error)=>{
if (status !== “success”){
console.log(error);
}
}
})
what are the function that you can use with ajax to retreive data
$.post(){}
$.get(){}
$.ajax(){}
or
sss
");