JS Operators and Methods Flashcards

1
Q

not

A

!

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

or

A

||

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

and

A

&&

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

how do you create a combination of booleans?

A

() for example
true && (true || false)
will derive true

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

equal to

A

===

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

not equal to

A

!==

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

addition

A

+

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

subtraction

A

-

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

multiplication

A

*

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

division

A

/

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

exponent

A

**

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

modulo

A

%

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

plus equals

A
\+=
example:  
x += y
x = x + y
incrementing x by y
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

minus equals

A

-=

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

times equals

A

*=

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

divide equals

A

/=

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

absolute value

A

Math.abs( )

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

round up

A

Math.ceil( )

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

round down

A

Math.floor( )

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

parsing an integer

A

parseInt( )

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

parsing a float

A

parseFloat( )

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

generate a number between 0 and 1

A

Math.random( )

23
Q

greater than

A

>

24
Q

greater than or equal to

A

> =

25
Q

less than

A
26
Q

less than or equal to

A

<=

27
Q

accessing a character in a string

A

string[index]
note: the index is the number that corresponds to the location of the character in the string. strings start at 0 in javascript.

28
Q

reassigning a string

A
leave off var, let or const and reassign the variable to the new value;
e.g. 
var someVarable = "something";
someVariable = "reassigned string";
29
Q

concatenate two or more strings

A

+

30
Q

string interpolation

A

+ string interpolation +

31
Q

get the length of a string

A

.length

32
Q

get the last character of a string

A

[ .length - 1]

e.g. “string”[“string”.length - 1]

33
Q

get a portion of a string

A

.substring(first index, last index]
i.e. “string”.substring(3, 4);
would derive “in”

34
Q

find where a portion of the string exists in a string

A

.indexOf( )
i.e. “string”.indexOf(“in”);
would derive 3
if it doesn’t exist, it derives -1

35
Q

turn a value into a string

A

.toString( )

36
Q

escape characters

A

\

37
Q

new line

A

\n

38
Q

create an array

A

[ ]

39
Q

access an element in an array

A

array name [index of element]
e.g.
var array = [1, 2, 3, 4];

var secondElement = array[1];
console.log('secondElement:', secondElement)
40
Q

reassigning an element in an array

A

array name [index] = “new value”;

note: arrays are mutable

41
Q

length of an array

A

.length

42
Q

last element of an array

A

array name[array name.length - 1]

almost identical to getting the last element in a string

43
Q

adding an element to the back of an array

A

.push( )

44
Q

removing an element from the back of an array

A

.pop( )

45
Q

adding an element to the front of an array

A

.unshift( )

46
Q

removing an element from the front of an array

A

.shift( )

47
Q

adding an element in general to an array

A
.splice(index, 0, adding element)
e.g.
var array = [1, 2, 4];
array.splice(2, 0, 3);
derives 1,2,3,4
48
Q

removing an element in general from an array

A

.splice(index, number of removing elements, adding elements if there are any)

49
Q

determine if a value is an array

A

Array.isArray( )

50
Q

taking parts of an array and creating a new array

A

.slice(start, end);

51
Q

add an array to another array

A

.concat

first array.concat(second array);

52
Q

transform an array into a string

A

.join( ) all elements added together into a string
.join(“ “) adds spaces
.join(“-“) would add a dash between each element

53
Q

transform a string into an array

A

.split( ) all elements added together in an array
.split(“ “) all elements added individually in an array
.split(“-“)if elements have dashes, it will add them individually in an array

54
Q

determine where in an array we can find a particular element

A

.indexOf( )