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
Q

how are arrays different from plain objects?

A

the properties are numeric

26
Q

first index of array

A

0

27
Q

how do you calculate the last index of an array?

A

array.length - 1

28
Q

What is a function in JavaScript?

A

a reusable group of tasks to return and receive different values.

29
Q

Describe the parts of a function

A

function name(parameters) {codeblock};

30
Q

describe the parts of a function call

A

name (arguments);

31
Q
  • When comparing them side-by-side, what are the differences between a functioncalland a functiondefinition?
A

a definition has parameters, codeblock, keyword. A call has arguments.

32
Q

What is the difference between a parameter and argument?

A

the parameter is the placeholder for an argument.

33
Q

why are function parameters useful?

A

without them the function would do the same thing every time.

34
Q

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

A

exits the codeblock and gives back the value.

35
Q

what is a method?

A

function thats been saved into an object

36
Q

How is a method different from any other function?

A

Methods are functions stored into property of an object.

37
Q

remove the last element from an array

A

.pop();

38
Q

round a number down to the nearest integer?

A

Math.floor(); or Math.trunc();

39
Q

generate a random number

A

Math.random();

40
Q

delet an element from an array

A

.splice();

41
Q

append an element to an array

A

.push();

42
Q

break up a string into array?

A

.split();

43
Q

Do string methods change the original string? How can you check if unsure?

A

No, log the original string

44
Q

is the return value of a function useful in every situation?

A

No

45
Q

6 examples of comparison operators

A

> > = < <= === !==

46
Q

data type comparsion expressions evaluate to

A

boolean

47
Q

purpose of an if statement

A

add conditions to the code.

48
Q

is else required for proper if statement?

A

NO

49
Q

syntax of if statement

A

if (condition) {declaration};

50
Q

three logical operators

A

&& || !

51
Q

How do you compare two expressions in the same condition?

A

logical operator

52
Q

purpose of a loop

A

repeated block of code happening until the conditions stated are false

53
Q

Purpose of a condition expression

A

The brake of the loop, waiting until the boolean is false.

54
Q

what is an iteration in the context of loops?

A

one repetition of the loop.

55
Q

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

A

before each iteration

56
Q

when does the intialization expression of a for loop get evaluated?

A

it happens first, before anything else in the loop and it happens only once.

57
Q

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

A

after the intialization and it happens before each iteration

58
Q

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

A

at the end of each iteration and before the condition

59
Q

Besides areturnstatement, which exits its entire function block, which keyword exits a loop before itsconditionexpression evaluates tofalse?

A

break

60
Q

the ++ operator

A

adds 1

61
Q

how do you iterate through the keys of an object?

A

for in loop