Basics Flashcards

1
Q

declare a variable

A

let varrr = 123;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

local scope variable

A

let tmp = “test”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

global scope variable

A

var tmp = “test”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

constant variable

A

const tmp = “3.1411414”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

declare a table

A

let tab = []; or let tab = Array();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is the function that adds a new element to the end of an array

A

.push(element);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is the function that adds a new element to the start of an array

A

.unshift(element);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is the function that adds one or multiple elements to some position in the array

A

.splice(<start>, <delete>, <element1>, <element2>....);</element2></element1></delete></start>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what function removes one or multiple elements from some position in an array and return the deleted values in a list

A

.splice(<start>, <delete>);</delete></start>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what function removes the last element from a list

A

.pop()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what function removes the first element in a list

A

.shift()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

how to access an element in a list

A

by it’s index

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

what is the function that gets all element with the same class name

A

document.getElementById(<”id”>)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what is the function that gets all elements with the same tag name

A

document.getElementsByTagName(<”tag name”>)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what is the function that gets an element with a unique id

A

document.getElementById(<”id”>);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

what is the function that gets the first child node of an element

A

<element>.firstChild();
</element>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

what is the function that gets the first child element of an element

A

<element>.firstElementChild();
</element>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

what is the function that gets you the next sibling node of an element

A

<element>.nextSibling()
</element>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

what is the function that gets you the previous sibling node of an element

A

<element>.previousSibling()
</element>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

what is the function that gets the next element sibling of an element

A

<element>.nextElementSibling()
</element>

21
Q

what is the function that gets the previous element sibling of an element

A

<element>.previousElementSibling()
</element>

22
Q

what is XMLHttpRequest

A

a JavaScript object that allows the developer to retrieve data from an endpoint with out reloading a page

23
Q

how to use $.ajax try to remember the syntax

A

$.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);
}
}
})

23
Q

what are the function that you can use with ajax to retreive data

A

$.post(){}
$.get(){}
$.ajax(){}

24
Q

how to get html content of an element

A

<element>.innerHtml;
</element>

25
Q

how to get the Text inside of an element

A

<element>.innerText;
</element>

26
Q

how to get the text of an element like <p> or <h></h>

A

<element>.textContent;
</element>

27
Q

how to get the value of an element in js

A

<element>.value;
</element>

28
Q

(jquery) how to get an element with an id

A

$(“#id”);

29
Q

(jquery) how to get elements with a tagname

A

$(“p”);

30
Q

(jquery) how to get elements with a class name

A

$(“.class_name”);

31
Q

(jquery) what function does hide an element

A

$(“#element”).hide();

32
Q

(jquery) what function does remove an element

A

$(“#element”).remove();

33
Q

(jquery) what is the function that gets the innerHtml of an element

A

$(“#element”).html();

34
Q

(jquery) what is the function that sets the innerHtml of an element

A

$(“#element”).html(“<p>sss</p>”);

35
Q

(jquery) what is the function that gets the inner text of an element

A

$(“#element”).text();

36
Q

(jquery) what is the function that sets the inner text of an element

A

$(“#element”).text(“OFHFSBF”);

37
Q

(jquery) what is the function that gets the value of an element

A

$(“#element”).val();

38
Q

(jquery) what is the function that removes a class

A

$(“#element”).removeClass(“class_name”);

39
Q

(jquery) what is the function that adds a new class

A

$(“#element”).addClass(“class_name”);

40
Q

(jquery) what is the function that adds a new attribute

A

$(“#element”).attr(“atrName”, “afaf”);

41
Q

(jquery) what is the function that removes an attribute from an element

A

$(“#element”).removeAttr(“Attr_name”);

42
Q

(jquery) what is the function that checks if an element has a class

A

$(“#element”).hasClass(“class_Name”);

43
Q

how to get all the classes in an array from an element

A

.classList()

44
Q

how to add a class in an element

A

.classList.add(“class_name”);

45
Q

how to remove a class from an element

A

.classList.remove(“class_name”);

46
Q

how to add a new attribute

A

.setAttribute(“attr”, “value”);

47
Q

how to remove an attribute

A

.removeAttribute(“attr_NAME”)