javascripot Flashcards

1
Q

What is the purpose of variables?

A

to store values

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

How do you declare a variable?

A

var name

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

period, undrescore, characters $#@, and letters

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

a capital letter changes the variable, different variable

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

store characters

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

numerical value to math or store

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

gives true/false values

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

What does the = operator mean in JavaScript?

A

assign value

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

How do you update the value of a variable?

A

assign a new value to the variable

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

What is the difference between null and undefined?

A

null is intentionally undefined, undefined was just never given any value

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

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

A

so you know what is logging what in longer code.

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

Give five examples of JavaScript primitives.

A

undefined, null, boolean, string and number

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

What is string concatenation?

A

appending a string onto another string

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

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

A

arithmetic addition and string concatenation

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

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

A

sets the value to the value plus the number

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

What are objects used for?

A

groups set of variables and functions to create a model of something

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

What are object properties?

A

a variable that is part of an object

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

Describe object literal notation.

A

setting a var object = {}

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

How do you remove a property from an object?

A

using the delete keyword

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

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

A

dot notation and bracket notation

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

What are arrays used for?

A

set of values related to each other, a list

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

Describe array literal notation.

A

var array = []

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

How are arrays different from “plain” objects?

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

What is the length property of an array?

A

How many values are int he array

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

How do you calculate the last index of an array?

A

.lenght-1

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

What is a function in JavaScript?

A

set of code that takes arguments and can be called

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

Describe the parts of a function definition.

A
function operator-name of function(parameters) {
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

Describe the parts of a function call.

A

function(arguments);

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

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

A

function definition uses function keyword, calling uses the function name and arguments.

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

What is the difference between a parameter and an argument?

A

parameters are placeholders that can store arguments.

35
Q

Why are function parameters useful?

A

Makes functions reusable with different arguments.

36
Q

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

A

Causes the function to produce a value we can use in our program.
Prevents any more code in the function’s code block from being run.

37
Q

Why do we log things to the console?

A

Check console output to see where we are in code and for errors

38
Q

What is a method?

A

a function which is a property of an object

39
Q

How is a method different from any other function?

A

it is associated with an object

40
Q

How do you remove the last element from an array?

A

.pop

41
Q

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

A

math.floor

42
Q

How do you generate a random number?

A

math.random

43
Q

How do you delete an element from an array?

A

.splice

44
Q

How do you append an element to an array?

A

.push or .unshift or .splice(0 placement appended)

45
Q

How do you break a string up into an array?

A

.split

46
Q

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

A

no. console.log the string before and after the method

47
Q

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

A

~30

48
Q

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

A

no. push, unshift return length of array- splice returns spliced element.

49
Q

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

A

MDN

50
Q

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

A

~30

51
Q

Give 6 examples of comparison operators.

A

great, less than, greater =, lesser =, equal to, not equal to, strictly equal to

52
Q

What data type do comparison expressions evaluate to?

A

boolean

53
Q

What is the purpose of an if statement?

A

determines execution path based on a condition

54
Q

Is else required in order to use an if statement?

A

No

55
Q

Describe the syntax (structure) of an if statement.

A

if (condition) {
code
};

56
Q

What are the three logical operators?

A

&&, ||, !

57
Q

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

A

if else

58
Q

What is the purpose of a loop?

A

to reiterate code during a condition

59
Q

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

A

to tell the loop when to stop iterating

60
Q

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

A

one time through the loop

61
Q

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

A

at the beginning before code block runs.

62
Q

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

A

at the start once before iteration

63
Q

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

A

after initialization and before the code runs

64
Q

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

A

before the condition expression.

65
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.

66
Q

What does the ++ increment operator do?

A

adds 1

67
Q

How do you iterate through the keys of an object?

A

for in loop

68
Q

What is a method?

A

function which is a property of an object.

69
Q

How can you tell the difference between a method definition and a method call?

A

call is object.methodname definition is methodname: function ()

70
Q

Describe method definition syntax (structure).

A
var object = {
 methodname: function(){
}
}
71
Q

Describe method call syntax (structure).

A

object.methodname

72
Q

How is a method different from any other function?

A

tied to an object

73
Q

What is the defining characteristic of Object-Oriented Programming?

A

based on objects and procedures

74
Q

What are the four “principles” of Object-Oriented Programming?

A

Abstraction
Encapsulation
Inheritance
Polymorphism

75
Q

What does API stand for?

A

Application programming interface

76
Q

What is the purpose of an API?

A

simplify for users

77
Q

What is this in JavaScript?

A

this keyword refers to an object.

this is an implicit parameter of all JavaScript functions.

78
Q

What does it mean to say that this is an “implicit parameter”?

A

parameter not explicitly defined

79
Q

When is the value of this determined in a function; call time or definition time?

A

call time

80
Q
What does this refer to in the following code snippet?
var character = {
  firstName: 'Mario',
  greet: function () {
    var message = 'It\'s-a-me, ' + this.firstName + '!';
    console.log(message);
  }
};
A

Mario

81
Q

Given the above character object, what is the result of the following code snippet? Why?
character.greet();

A

It’s a me Mario!

because the this.firstName calls the character object to fill the statement

82
Q
Given the above character object, what is the result of the following code snippet? Why?
var hello = character.greet;
hello();
A

undefined

83
Q

How can you tell what the value of this will be for a particular function or method definition?

A

it is defined at definition

84
Q

How can you tell what the value of this is for a particular function or method call?

A

the value of this can be recognized as “the object to the left of the dot” when the function is called (as a method).