JavaScript Flashcards

1
Q
  • What is the purpose of variables?
A

Stores data to be used later

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  • How do youdeclarea variable?
A

keyword name = value;

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

assignment operator

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

anyletter, $ _ or number(cant be first character)

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

the case sizing matters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  • What is the purpose of a string?
A

not code read by JS strings contain values to be saved as they are.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
  • What is the purpose of a number?
A

used for math, or numeric values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
  • What is the purpose of a boolean?
A

true or false, the logic of JS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
  • How do you update the value of a variable?
A

name = value;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
  • What is the difference betweennullandundefined?
A

null is intentionally assigned by programmer and is an intentional emptiness. Undefined is a JS assignment which declares a variable to have no arguments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
  • Why is it a good habit to include “labels” when you log values to the browser console?
A

to see what your console log is

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
  • Give five examples of JavaScript primitives.
A

boolean, null, undefined, string, number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
  • What data type is returned by an arithmetic operation?
A

numbers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
  • What is string concatenation?
A

combines words

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
  • What purpose(s) does the+plus operator serve in JavaScript?
A

adds valuess and concatenates strings

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
  • What data type is returned by comparing two values (,===, etc)?
A

boolean

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q
  • What does the+=”plus-equals” operator do?
A

adds values and assigns them

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

What are objects used for?

A

create a model for information, like a phonebook

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

what are object properties?

A

Obj {property: value}

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

Object literal notation

A

{value, value,….};

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
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
22
Q

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

A

dot notation or square brackets

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

what are arrays used for

A

storing a list of information

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

describe array literal notation

A

[value,value,….];

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
how are arrays different from plain objects?
the properties are numeric
26
first index of array
0
27
how do you calculate the last index of an array?
array.length - 1
28
What is a function in JavaScript?
a reusable group of tasks to return and receive different values.
29
Describe the parts of a function
function name(parameters) {codeblock};
30
describe the parts of a function call
name (arguments);
31
* When comparing them side-by-side, what are the differences between a function call and a function definition?
a definition has parameters, codeblock, keyword. A call has arguments.
32
What is the difference between a parameter and argument?
the parameter is the placeholder for an argument.
33
why are function parameters useful?
without them the function would do the same thing every time.
34
What two effects does a return statement have on the behavior of a function?
exits the codeblock and gives back the value.
35
what is a method?
function thats been saved into an object
36
How is a method different from any other function?
Methods are functions stored into property of an object.
37
remove the last element from an array
.pop();
38
round a number down to the nearest integer?
Math.floor(); or Math.trunc();
39
generate a random number
Math.random();
40
delet an element from an array
.splice();
41
append an element to an array
.push();
42
break up a string into array?
.split();
43
Do string methods change the original string? How can you check if unsure?
No, log the original string
44
is the return value of a function useful in every situation?
No
45
6 examples of comparison operators
> >= < <= === !==
46
data type comparsion expressions evaluate to
boolean
47
purpose of an if statement
add conditions to the code.
48
is else required for proper if statement?
NO
49
syntax of if statement
if (condition) {declaration};
50
three logical operators
&& || !
51
How do you compare two expressions in the same condition?
logical operator
52
purpose of a loop
repeated block of code happening until the conditions stated are false
53
Purpose of a condition expression
The brake of the loop, waiting until the boolean is false.
54
what is an iteration in the context of loops?
one repetition of the loop.
55
when does the condition expression of a while loop get evaluated?
before each iteration
56
when does the intialization expression of a for loop get evaluated?
it happens first, before anything else in the loop and it happens only once.
57
when does the condition expression of a for loop get evaluated?
after the intialization and it happens before each iteration
58
when does the final expression of a for loop get evaluated?
at the end of each iteration and before the condition
59
Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?
break
60
the ++ operator
adds 1
61
how do you iterate through the keys of an object?
for in loop