Js Flashcards

1
Q

How can we deleet everything in chrome Console ?

A

type: clear
or
ctrl + k

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

How to get to console directly ?

A

command + option + j
or
got to view => developer=> javascript console

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

+

A

addition

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

-

A

subtraction

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

*

A

Multiplication

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

/

A

Division

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

%

A

Modulo

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

what is prder operations ?

A

PEMDAS

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

what is PEMDAS

A

parantheses, exponents, Multiplication, division, addition, substraction

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

how can i recall previous run lines ?

A

with up/down arrow

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

how tp make a comment in Js ?

A

with //

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

modulo known also as ?

A

remeinder operator

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

how to to pronaunce modulo ?

A

madulo

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

what means 9%2

A

it means two goes into nine how many time as a whole number, and how much will be remain ?
9%2 = 1

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

modulo ist commen to use where ?

A

to determine if a number is even or odd

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

how to write 2²?

A

2**2

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

what Nan stand for ?

A

not a number

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

NaN consider as what is js ?

A

consider as a number

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

0/0 =

A

NaN

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

how to check js consider an ellement as what ?

A

with command typeof
ex: typeof 4 = number

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

what is variable ?

A

it is the way of giving some name to a value and sorting it using js.

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

how we make a variable ?

A

let year =. 1985;

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

how to update the value of a variable ?

A

imagine we have let numApple = 4;
- write it again : numApple = 5;
or
-numApple = numApple + 1
or
-numApple +=5
-numApple -=5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q
  • if i had totalFruits= numApple + num Orange in previouse liene and than I updated numApple, how can i update totalFruits value ?
A

just write totalFruits= numApple + num Orange again

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

score ++; =

A

score+=1;

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

score–; =

A

Score-=1;

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

what Const stand for ? and what is it ?

A

Constant, it is a value that does not change

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

What is VAR ?

A

BEFORE LET AND CONST, VAR was the only way of Declaring variables. these days it is not commen to use.

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

How many optons do we have for a Boolean value ?

A

two, true or false

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

Whats is Booleann use to ?

A

to store yes or no, True or false
Ex numPuppies = false;

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

js hard ruls:

A

-we cant have space between our name
- we cant have number at begining of my name
- the Names are case sensitiv
these names can contain also $ and

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

what is the other name for Number ?

A

identifier

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

what is the name of this type of typing numberOfBoys ?

A

camel cased

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

by Boolean it is better how to name them ?

A

instead of gameOver = True;
isGameOver

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

What is String ?

A

It textual information, they reprecents text, and they must be wrapped in quots.
let username = “pouya”;
- we can have space in between
-we can have $
-we can have numbers
-it can be zero character lang
- we can use one string inside another string
“I´love´you “
- we cant do like that
“I”love”you “

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

string index start with which number ?

A

0

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

How can I access indexes of my string ?

A

let animal = “cat”;
animal[1] = “a”

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

what is concatenation ?

A

“lol”+”lol”= “lollol”

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

a combination of number and string is :

A

string

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

msg.toUppercase ()
what is toUpperCase () ?

A

it is a method

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

with which method can we upper case our string ?

A

.toUpperCase ()

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

with which method can we lower case our string ?

A

.toLowerCase ()

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

what is trim Method ?

A

it is going to trim off any whitespace at the begining of a string or at the end.

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

we can chain methids together

A

.

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

what is arguments ?

A

are inputs that we can pass into the method to alter how they behave
ex: searchFor(“a”) “a” is an argument.

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

what is indexOf method?

A

its going to give us the string index and positional number where a given argument occurs in a string.

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

what is slice method?

A

it can accept more than one argument .
it is going to extract or slice a portion of a string and it returns it or give it to us as a new string.
let msg = “haha that is so funny!”
msg.slice(5) =”that is so funny!”
or
“haha that is so funny!”.slice(5)
or
msg.slice(5, 10)

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

what is replace method?

A

msg.replace (“haha”,”lol”)

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

what is repeat method?

A

“lol”.repeat(10) = “lollollollollollollollollollol”

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

what is Template Literal ?

A

these Templates allows us to create strings where we can embed an expression inside the string and that expression will be evaluated and turned into a string.
´I counted ${x+y} sheep´

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

Template Literals only works with back ticket, what is back ticket ?

A

´´

52
Q

what is the pronaunciation for null

A

nol

53
Q

what is undifined

A

it is the way of js sayin, I dont know. I dont know what do you want.

54
Q

what is null

A

it is a value we can set for a variable

55
Q

what is The Math object ?

A

it´s a collection of properties and methods that have to do with math in some way.

56
Q

what is math.floor ?

A

it will take a number with a decimal and chop of that decimal, so it´s not rounding.

Ex: math.floor (23.9999999) = 23

57
Q

Math.ceil (34.1) =

A

35

58
Q

what is math.random ()

A

it will give us random numbers between 0 an 0.999999999

59
Q

make random number beween 1 and 10

A

Math.floor(math.random()*10)+1

60
Q

>

A

greater than

61
Q

<

A

less than

62
Q

> =

A

greater than or equal

63
Q

==

A

equality

64
Q

!=

A

not equal

65
Q

===

A

strict equality

66
Q

!==

A

strict non equality

67
Q

what is unicode ?

A

underlying code of every character

68
Q

what is the diffrence between == and ===

A

===checks the type too

69
Q

how we print our arguments in js ?

A

console.log()

70
Q

alert

A

it gonna pop up an alert user

71
Q

prompt

A

it is gonna accept an argument

72
Q

how do i connect my html and js

A

I will write


in the end of my body in html
73
Q

what is if statement ?

A

my code will run if given condition is true
let rating =3;
if (rating===3){
console.log(“You are a super star”);
}

74
Q

what is else if statement ?

A

if the if part was false, then maybe try this other thing
et rating =3;
if (rating===3){
console.log(“You are a super star”);
}
else if (rating===2){
console.log(“Meets Expectitations”)
}
* we can have as many else if as we want

75
Q

is the order of else ifs matter ?

A

yes, so much

76
Q

what is else statement ?

A

else going to be the last part. it is always last piece.
if (rating===3){
console.log(“You are a super star”);
}
else if (rating===2){
console.log(“Meets Expectitations”)
}
else {
console.log(“Meh”)
}

77
Q

every single value in js have truthy exept

A

1- false
2- 0
3- “” (empty string
4- null
5- undifined
6-NaN

(these are falsy)

78
Q

what is logical operators ?

A

logical operators are operators that allow us to combine diffrent expressions

79
Q

logical operators => and

A

&&

80
Q

logical operators=> or

A

II

81
Q

logical operators=> not

A

!

82
Q

in order to logical operator ´and´ gonna be true, what is important ?

A

the left and right side must be true

83
Q

in order to logical operator ´or´ gonna be true, what is important ?

A

it doesnt need both part to be true, in order whole thing to be true, it just need one part to be true

84
Q

what does ´not´ logical operator ?

A

it is going to negate the value, if its true it will change it to false, if its fals it change it to true

85
Q

what is Arrays ?

A

-it is a collection of values.
-it is an ordered collection of values
- it is an array: []

86
Q

imagine we have this array:
days[1] = “Tursday”
How can I get “T” from it ?

A

days [1][1]

87
Q

how can we update an array ?

A

by typing it again with the new value

88
Q

how to update a string ?

A

it is not possible

89
Q

what does ´push and pop ´

A

it allow us to add and remove from the end of an array

90
Q

How to use push ?

A

let movie = [“tom”,”jerry”]
movie.push (“alice”,”elford”)

91
Q

how to use pop ?

A

movie.pop() and it will remove an element from the end

92
Q

what is shift and unshift ?

A

shift removes from the beginning of an array
unshift remove add to beginning

93
Q

how we use shift ?

A

movie.shift()

94
Q

How to use unshift ?

A

movie.unshift (“jordan”,”petter”)

95
Q

what is concat ?

A

we mix two array and become the third array

96
Q

How do we use concat ?

A

let cat = [“kitty”,”blue”]
let dog =[“dokme”,”chakme”]
cat.concat(doge)

97
Q

what is includes ?

A

it show us if an array contain a value in true or false.
cat.includes(“party”)

98
Q

what is a Reverse ?

A

it is going to reverse an array.

99
Q

what else happens when i use reverse ?

A

the original array also will be modified

100
Q

what are slice and splice ?

A

slice is the way of copying a slice of an array and
splice is going to change content of an array by removing or replacing existing elements or adding new ellements in place

101
Q

how to use slice ?

A

colorsd.sliche(3 )
it will start from 3 toward
colorsd.sliche(3, 5 )
it will take slice between index 3 and 5

102
Q

how to use splice ?

A

colors.splice (5,1)
it will remove one element at index 5
colors (5, 0, “red”)
at index of 1 it wiill remove nothing and just add red after that

103
Q

what is sort ?

A

if we just call array.sort() , it will change it to a string

104
Q

How to update a Const ?

A

it is not possible in normal way.
- it is possible if we mix it with array
ex:
const nums =. [1, 2, 3]

105
Q

imagine I have
const gane =[[“x”,”o”,”x”],[“o”,”null”,”x”],[“o”,”o”,”x”]]
how can i access null ?

A

game[1][1]

106
Q

js objects are made from what ?

A

key and value
let comment = {
username: “pouya”,
age : 30
tags: [ “#A”, “#B”, “#c”]
};

107
Q

how can we access pouya in this js object ?
key and value
let comment = {
username: “pouya”,
age : 30
tags: [ “#A”, “#B”, “#c”]
};

A

comment[“username”]
or
comments.username

108
Q

I have
const midterm {daniel: 79, susane: 89, marta: 70}
How can i update susane midterm ?
and how can i add a mark for azra ?

A

midterm.susane = 95;
midterm.azra = 80

109
Q

write a for loop

A

for (let i = 1; i++){
console.log(i);
}

110
Q

write a infinate loop

A

for (let i = 20; i>= 0; i++) {
console.log(i)
}

111
Q

write loop for
const animals = [ “lions”,”cats”,”dogs”];
I expect the resault will be
0 “lions”
1”cats”
2”dogs”

A

for (let i = 0; i<animals.length; i++) {
console.log(i, animals[i]);
}

112
Q

which alphabet do we usualy use for for loop?
which alphabet do we usualy use for first nested for loop ?
which alphabet do we usualy use for second nested for loop ?
which alphabet do we usualy use for third nested for loop ?

A

1- i
2- j
3- k
4- m
5- .
.
.
.

113
Q

We have
const seatingChart = [
[“kristen”,”erik”,”namita”],
[“geoffery”,”julia”,”antonio”,”kevin”],
[“yuma”,”sakura”,”jack”,”erika”]
]
how can we print out every name ?

A

for (let i = 0; i <seatigChart.length; i++) {
const row = seatigChart[i];
console.log(´ROW ${i+1}´)
for (let j = 0;vj <row.length; j++){
console.log([j])
}
}

114
Q

what is while loop

A

it has only one single condition and as long as this condition is true, our loop will continue to run.

115
Q

write a while loop

A

let num = 0;
while (num<10) {
console.log(num);
num++;
}

116
Q

what is the break keyword in js

A

-it usually use in while loop
-it causes the loop to exit immediately

117
Q

what is for… of

A

for…of allows you to iterate over the values of an iterable object like arrays, strings, maps and sets.
Syntax: ´for (const value of iterable) { // code }´
Use ´for…of´ when you need to iterate over the values of an iterable object, rather than the index.

118
Q

can use for…of only with what ?

A

only with iterable object

119
Q

what is for… in

A

-it is pretty uncommen these days.
-it will give us only key in the object

120
Q

what shold i di by for in if I want for … in too ?

A

for (let person in testScores){
console.log()´${person}scored ${testScores[person]}´);
}

121
Q

how many steps do we have to write an object ? what are them?

A

two steps:
1- define the function
2- execute it

122
Q

write a sample function

A

function functionName(){
//do something
}
funcName()

123
Q

what is argument ?

A

argument in js is fancy way of saying inputs to a function
function greet(firstName) {
console.logi(´firstName is: ${firstName}´)
}

====>firstName is an Argument

124
Q

write a function with multiple arguments

A

function greet(firstName,lastName) {
console.log(´Hey there, ${firstName}!´)
}

125
Q

What is Return ?

A

to have capturable value from function we need Return.
so instead of :
function add(x,y){
console.log(x+y)
}
we write:
function add(x,y){
return x+y;
}
console.log(x+y)

126
Q

what should be know about return keyword ?

A

-return keyword actually stops the execution of our function so wherever I have something aftewards, like console.log() , this line will not run
-we can only return a single value