Javascript quick study Flashcards

1
Q

remove from front

A

array.shift()

leave () blank

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

remove from back

A

array.pop()

leave () blank

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

add to front

A

array.unshift(new element)

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

add to back

A

array.push(new element)

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

absolute value

A
Math.abs(number)
//always positive
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

round up

A

Math.ceil(number)

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

round down

A

Math.floor(number)

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

Generate random number

A

Math.random() * (max - min) + min)

leave () blank

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

Not

A

!

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

Or

A

||

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

And

A

&&

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

Equal to

A

===

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

Not equal to

A

!==

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

Get character in a string

A

“string”[index]

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

Get length

A

.length

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

Get an element in an array

A

array[index]

17
Q

Is it an array

A

Array.isArray(input)

18
Q

Add arrays together

A

array1.concat(array2, array3)

19
Q

Turn a string into an array

A

“string”.split(“ “)

var name: “my name is”
name.split(“ “) = [“my”, “name”, “is”]
(“ “) means split at the space

20
Q

Copy an Array

A

array.slice()

21
Q

Access a value in an object

A

object[key]

22
Q

Remove a property (key: value) from an object

A

delete object[key]

23
Q

Average

A

Sum of numbers divided by amount of numbers

Example: 12 + 27 + 5 + 9 = 53. 53/5 = 10.6

24
Q

Area of a Triangle

A

(Base x Height) / 2

25
Q

Area of a Rectangle

A

Length * Width

26
Q

Perimeter of a Circle

A

2 * Math.PI * radius

27
Q

Code for PI

A

Math.PI

28
Q

Area of a Circle

A

Math.PI * radius ** 2

29
Q

Square Root

A

Math.sqrt(number)