JAVASCRIPT Flashcards

1
Q

What is the purpose of variables?

A

to store or remmeber information

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

How to declare a variable

A

var and name of variable

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

How do you initialize (assign a value to) a variable?

A

=

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

What characters are allowed in variable names?

A

$, any character, _, a number as long as its not in the beginning

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

What does it mean to say that variable names are “case sensitive”?

A

that capital letters affect it

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

How do you update the value of a variable?

A

re declare them

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

What is the difference between null and undefined?

A

null is put there by a programmer undefined is there in the absence of anything

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

Why is it a good habit to include “labels” when you log values to the browser console?

A

for readability

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

What data type is returned by an arithmetic operation?

A

number

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

What purpose(s) does the + plus operator serve in JavaScript?

A

concatination and addition

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

What data type is returned by comparing two values (, ===, etc)?

A

boolean type

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

What does the += “plus-equals” operator do?

A

adds the value to the current value and reasign the variable

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

What are objects used for?

A

to combine like information

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

What are object properties?

A

allow you to store information

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

Describe object literal notation.

A

var object ={}

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

How do you remove a property from an object?

A

delete operator

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

What are the two ways to get or update the value of a property?

A

. or []

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

What are arrays used for?

A

store a list of items

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

Describe array literal notation.

A

var array =[];

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

How are arrays different from “plain” objects?

A

objects have properties arrays don’t

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

What number represents the first index of an array?

A

0

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

What is the length property of an array?

A

the number of values in array

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

How do you calculate the last index of an array?

A

length -1

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

What is a function in JavaScript?

A

an set of instructions

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

Describe the parts of a function definition.

A

function name (parameter){code block}

26
Q

Describe the parts of a function call.

A

name of function and argument

27
Q

When comparing them side-by-side, what are the differences between a function call and a function definition?

A

function definition defines the function.

function call is calling the function

28
Q

What is the difference between a parameter and an argument?

A

parameter is just to hold value and has no value.

argument has a value.

29
Q

Why are function parameters useful?

A

it can be re used with different arguments

30
Q

What two effects does a return statement have on the behavior of a function?

A

it will return code outside of the function, and stops code from running after it

31
Q

Why do we log things to the console?

A

to debug

32
Q

What is a method?

A

a pre defined function which is a property of an object

33
Q

How is a method different from any other function?

A

you can only input arguments on methods, you can modify functions and how they work

34
Q

How do you remove the last element from an array?

A

.pop()

35
Q

How do you round a number down to the nearest integer?

A

Math.floor()

36
Q

How do you generate a random number?

A

Math.random()

37
Q

How do you delete an element from an array?

A

splice

38
Q

How do you break a string up into an array?

A

split

39
Q

Do string methods change the original string? How would you check if you weren’t sure?

A

no strings are immutable console.log

40
Q

Roughly how many string methods are there according to the MDN Web docs?

A

30

41
Q

Is the return value of a function or method useful in every situation?

A

depends not every situation

42
Q

Roughly how many array methods are there according to the MDN Web docs?

A

30ish

43
Q

What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?

A

mdn

44
Q

What data type do comparison expressions evaluate to?

A

boolean types

45
Q

What is the purpose of an if statement?

A

to make a decision

46
Q

Is else required in order to use an if statement?

A

no

47
Q

Describe the syntax (structure) of an if statement.

A

if (){}

48
Q

What are the three logical operators?

A

if, else, if else

49
Q

How do you compare two different expressions in the same condition?

A

|| &&

50
Q

What is the purpose of a loop?

A

check condition and run code block multiple times

51
Q

What is the purpose of a condition expression in a loop?

A

the thing that says start or stop

52
Q

What does “iteration” mean in the context of loops?

A

being repeated

53
Q

When does the condition expression of a while loop get evaluated?

A

before each iteration

54
Q

When does the initialization expression of a for loop get evaluated?

A

before loop starts

55
Q

When does the condition expression of a for loop get evaluated?

A

before initial iteration

56
Q

When does the final expression of a for loop get evaluated?

A

at the end after iteration

57
Q

Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?

A

break

58
Q

What does the ++ increment operator do?

A

increments by 1

59
Q

How do you iterate through the keys of an object?

A

for in loop

60
Q

what does the substr() method do

A

returns a portion of the string, starting at the specified index and extending for a given number of characters afterwards