LearningFuze Mod 1 - Javascript Flashcards

1
Q

What is the purpose of variables?

A

Variables are used to store information to be referenced and manipulated in a computer program.

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

How do you declare a variable?

A

assigning it with a 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

by adding an equals (assignment operator) to the var

Ex (var=””)

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

a letter a dollar sign $ or an underscore (_) or numbers but they CANNOT be in the start

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

It relies on camelCase

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 String object is used to represent and manipulate a sequence of 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

Store numeric value

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

it creates true or false statements

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

it assigns 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

We write the variable name and giving a new value would change it

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

undefined is a type by itself (undefined). … Here as the variable is declared but not assigned to any value, the variable by default is assigned a value of undefined. On the other hand, null is an object. It can be assigned to a variable as a representation of no 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

Because if you do not assign a value it will make a global value and it can break it

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

returns a single numerical value.

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

What is string concatenation?

A

joining two or more strings together to make one

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

It combines two strings and does addition

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 (

A

boolean, which is true or false statements

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

adds the value of the right operand to a variable and assigns the result to the variable.

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

What are objects used for?

A

Its used to model

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

What are object properties?

A

Is a variable

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

Describe object literal notation.

A

NEEDED

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

.notion or bracket notion

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

What are arrays used for?

A

To store values

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

How are arrays different from “plain” objects?

A

They are numerical index

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Describe array literal notation.
NEEDED
26
What is the length property of an array?
it records the values in the array
27
How do you calculate the last index of an array?
length of the array -1
28
What is a function in JavaScript?
Block of code and call as needed
29
Describe the parts of a function definition.
The function keyword, optional name, the perimeter list and the end of the code block
30
Describe the parts of a function call.
to call, we use the name (if it has one) and the parentheses
31
When comparing them side-by-side, what are the differences between a function call and a function definition?
NEEDED
32
What is the difference between a parameter and an argument?
NEEDED
33
Why are function parameters useful?
Stores data so the function can use
34
What two effects does a return statement have on the behavior of a function?
NEEDED
35
Why do we log things to the console?
To show the output in our javascript
36
What is a method?
A method is a function which is a property of an object.
37
How is a method different from any other function?
a method is associated with an object
38
How do you remove the last element from an array?
by using the pop method
39
How do you round a number down to the nearest integer?
by using the math.floor() method
40
How do you generate a random number?
by using .random() method
41
How do you delete an element from an array?
the pop method, shift method or the splice method
42
How do you append an element to an array?
the .push() method appends and the unshift method prepends it
43
Do string methods change the original string? How would you check if you weren't sure?
No it will not change the original string and you can check it with the console log
44
Roughly how many string methods are there according to the MDN Web docs?
Around 30+
45
Is the return value of a function or method useful in every situation?
No
46
Roughly how many array methods are there according to the MDN Web docs?
Around 30+
47
What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?
MDN
48
Give 6 examples of comparison operators.
== is equal to, != is not equal to, > greater than, < less than, >= greater than or equal to, <= less than or equal to
49
What data type do comparison expressions evaluate to?
Boolean
50
What is the purpose of an if statement?
it makes checks on functions to do a certain action
51
What are the three logical operators?
&& logical and, || logical or, ! logical not
52
Describe the syntax (structure) of an if statement.
NEEDED
53
What is the purpose of a loop?
Run a block of code until a certain amount of time or the condition is met
54
What is the purpose of a condition expression in a loop?
the last thing we do before we start the code thats inside of the loop
55
What does "iteration" mean in the context of loops?
It's the process of repeating the loop
56
When does the condition expression of a while loop get evaluated?
It's before each time and after each iteration
57
When does the initialization expression of a for loop get evaluated?
One time before the loop begins
58
When does the condition expression of a for loop get evaluated?
Before each iteration
59
When does the final expression of a for loop get evaluated?
After the work of the conditional expression
60
Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?
break; would be the keyword
61
What does the ++ increment operator do?
It increments by 1
62
How do you iterate through the keys of an object?
with a for in loop
63
What event is fired when a user places their cursor in a form control?
focus event
64
What event is fired when a user's cursor leaves a form control?
blur event
65
What event is fired as a user changes the value of a form control?
Input event
66
What event is fired when a user clicks the "submit" button within a ?
submit event
67
What does the event.preventDefault() method do?
Cancels the event if its cancelable
68
What does submitting a form without event.preventDefault() do?
Submits it back to the page
69
What property of a form control object gets and sets its value?
Value property
70
What is one risk of writing a lot of code without checking to see if it works so far?
You can have an error in your code and you will have to dig to see what is wrong with it.
71
What is an advantage of having your console open when writing a JavaScript program?
Its useful to see if you are getting error messages