javascript Flashcards

1
Q

What is the purpose of variables?

A

The purpose of variables is to store data

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

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

letters numbers dollarsign and number not at beggining

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

variables with different cases are different variables

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

The purpose of a string is to store text data

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

The purpose of a number is to store numbers, and perform math.

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

The purpose of a boolean is to denote if something is true or false

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

the equals operator assigns a value to a variable

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

You update the value of a variable by using the = sign

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 assigned on purpose, undefined is not assigned on purpose

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

What is string concatenation?

A

The operation of combining strings into one single string

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

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

A

It adds a value to a variable. It acts as a shorthand for var = var + value

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

What are objects used for?

A

For storing different but related pieces of data, and functions to perform operation on related data.

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

What are object properties?

A

Object properties are variables belonging to an object

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

Describe object literal notation.

A

Object literal notation is a way of defining an object in javascript.

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

How do you remove a property from an object?

A

the delete operator

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

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

A

bracket notation and dot notation

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

What are arrays used for?

A

Arrays are used for storing data in an indexed format

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

Describe array literal notation

A

Array literal notation is a way to describe arrays in your code

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

How are arrays different from “plain” objects”

A

Arrays are indexed

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

What is the length property of an array?

A

it gives the number of values in the array

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

How do you calculate the last index of an array

A

you take the length property and subtract it by one.

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

What is a function in JavaScript?

A

A function is a block of code that can be run, and have values passed in, and out.

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

Describe the parts of a function definition.

A

The function name, the function code block, the function return, the function parameters.

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

Describe parts of a function call.

A

the function name, the function arguments.

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

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

A

The function definition has a code block and can have a return statement, the function call has parameter values for arguments.

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

What is the difference between a parameter and an argument?

A

A parameter describes content that will be passed at some point into a function, an argument is a value being passed into a method we are calling.

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

Why are function parameters useful?

A

They help us pass data into functions so that they can be self contained (scope)

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

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

A

It returns a value, and stops code execution of the function code block.

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

Why do we log things to the console?

A

To debug our code

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

What is a method?

A

a method is a function belonging to an object

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

How is a method different from any other function?

A

a method is different because it is called from a function using dot notation

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

How do you remove the last element from an array?

A

array.pop

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

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

A

Math.floor()

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

How do you generate a random number?

A

Math.random()

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

How do you delete an element from an array?

A

array.splice()

40
Q

How do you append an element to an array?

A

array.push()

41
Q

How do you break a string up into an array?

A

string.split();

42
Q

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

A

String methods do not change the original string because strings are immutable. You would check using the console.

43
Q

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

A

3

44
Q

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

A

No

45
Q

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

A

30

46
Q

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

A

MDN

47
Q

Give 6 examples of comparison operators.

A

< > <= >= <== >== == === | | &&

48
Q

What data type do comparison expressions evaluate to?

A

boolean

49
Q

What is the purpose of an if statement?

A

Do introduce logic into code

50
Q

Is else required in order to use an if statement?

A

no

51
Q

Describe the syntax (structure) of an if statement.

A

conditional code block, condition, conditional statement

52
Q

What are the three logical operators?

A

if else ( else if )

53
Q

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

A

you chain them together using an or or an and, you can also use parentheses to group together expressions that should be evaluated first.

54
Q

What is the purpose of a loop?

A

The purpose of a loop is to iterate through data, or perform an action a certain or indefinite number of times based on a conditional.

55
Q

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

A

The purpose of the condition expression is to halt the operation of the condition when certain conditions are met, or to skip over the expression entirely.

56
Q

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

A

iteration means a repitition of the loop.

57
Q

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

A

during the beginning of each iteration.

58
Q

When does the initilization expression for a for loop get evaluated?

A

during the beginning of the first iteration

59
Q

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

A

during each iteration.

60
Q

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

A

the beginning of each iteration before the conditional.

61
Q

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

A

break

62
Q

What does the ++ increment operator do?

A

adds 1 to a variable

63
Q

How do you iterate through the keys of an object?

A

Using a for each loop

64
Q

What event is fired when a user places their cursor in a form control?

A

hover

65
Q

What event is fired when a user’s cursor leaves a form control?

A

blur

66
Q

What event is fired as a user changes the value of a form control?

A

input

67
Q

What event is fired when a user clicks the “submit” button within a ?

A

submit

68
Q

What does the event.preventDefault() method do?

A

prevents a form from performing its default action when used.

69
Q

What property of a form element object contains all of the form’s controls.

A

elements

70
Q

What property of form a control object gets and sets its value?

A

name.value

71
Q

What is one risk of writing a lot of code without checking to see if it works so far?

A

bugs, long debug times

72
Q

What is an advantage of having your console open when writing a JavaScript program?

A

you can see bugs right away.

73
Q

What is JSON?

A

JSON is a way of storing JavaScript objects in strings

74
Q

What are serialization and deserialization?

A

They are the process of taking data and organizing it in a way that can be better understood

75
Q

Why are serialization and deserialization useful?

A

They allow us to transmit and receive data in formats that are usable.

76
Q

How do you serialize a data structure into a JSON string using JavaScript?

A

JSON.stringify()

77
Q

How do you deserialize a JSON string into a data structure using JavaScript?

A

JSON.parse()

78
Q

What does the new operator do?

A

The new operator creates a new instance of a function and runs it.

79
Q

What property of JavaScript functions can store shared behavior for instances created with new?

A

prototype

80
Q

What does the instanceof operator do?

A

Checks if the prototype is an instance of a function

81
Q

What kind of inheritance does the JavaScript programming language use?

A

prototypal inheretence

82
Q

What is a prototype in JavaScript?

A

A prototype is an object that stores functions.

83
Q

How is it possible to call methods on strings, arrays, and numbers even though those methods don’t actually exist on objects, arrays, and numbers?

A

inheretence

84
Q

If an object does not have it’s own property or method by a given key, where does JavaScript look for it?

A

it’s protoype chain

85
Q

What is this in JavaScript?

A

this refers to the current instance of the object

86
Q

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

A

it is included with every function

87
Q

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

A

during run time

88
Q

What is a method?

A

A method is a function belonging to an object

89
Q

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

A

A method definition has no parentheses, and has a code block

90
Q

Describe method definition syntax (structure).

A

function hello(name) { }

91
Q

Describe method call syntax (structure).

A

hello(‘humberto’)

92
Q

How is a method different from any other function?

A

A method is different because it belongs to an object

93
Q

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

A

Abstraction Inheretence Polymorphism Encapsulation

94
Q

What is “abstraction”?

A

Taking something complex and making it easy to use

95
Q

What does API stand for?

A

Application programming interface

96
Q

What is the purpose of an API?

A

To make it easy for others to use data in your application in their programs.