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
Q

Describe array literal notation.

A

NEEDED

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

What is the length property of an array?

A

it records the values in the array

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

How do you calculate the last index of an array?

A

length of the array -1

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

What is a function in JavaScript?

A

Block of code and call as needed

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

Describe the parts of a function definition.

A

The function keyword, optional name, the perimeter list and the end of the code block

30
Q

Describe the parts of a function call.

A

to call, we use the name (if it has one) and the parentheses

31
Q

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

A

NEEDED

32
Q

What is the difference between a parameter and an argument?

A

NEEDED

33
Q

Why are function parameters useful?

A

Stores data so the function can use

34
Q

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

A

NEEDED

35
Q

Why do we log things to the console?

A

To show the output in our javascript

36
Q

What is a method?

A

A method is a function which is a property of an object.

37
Q

How is a method different from any other function?

A

a method is associated with an object

38
Q

How do you remove the last element from an array?

A

by using the pop method

39
Q

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

A

by using the math.floor() method

40
Q

How do you generate a random number?

A

by using .random() method

41
Q

How do you delete an element from an array?

A

the pop method, shift method or the splice method

42
Q

How do you append an element to an array?

A

the .push() method appends and the unshift method prepends it

43
Q

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

A

No it will not change the original string and you can check it with the console log

44
Q

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

A

Around 30+

45
Q

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

A

No

46
Q

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

A

Around 30+

47
Q

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

A

MDN

48
Q

Give 6 examples of comparison operators.

A

== is equal to, != is not equal to, > greater than, < less than, >= greater than or equal to, <= less than or equal to

49
Q

What data type do comparison expressions evaluate to?

A

Boolean

50
Q

What is the purpose of an if statement?

A

it makes checks on functions to do a certain action

51
Q

What are the three logical operators?

A

&& logical and, || logical or, ! logical not

52
Q

Describe the syntax (structure) of an if statement.

A

NEEDED

53
Q

What is the purpose of a loop?

A

Run a block of code until a certain amount of time or the condition is met

54
Q

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

A

the last thing we do before we start the code thats inside of the loop

55
Q

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

A

It’s the process of repeating the loop

56
Q

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

A

It’s before each time and after each iteration

57
Q

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

A

One time before the loop begins

58
Q

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

A

Before each iteration

59
Q

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

A

After the work of the conditional expression

60
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; would be the keyword

61
Q

What does the ++ increment operator do?

A

It increments by 1

62
Q

How do you iterate through the keys of an object?

A

with a for in loop

63
Q

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

A

focus event

64
Q

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

A

blur event

65
Q

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

A

Input event

66
Q

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

A

submit event

67
Q

What does the event.preventDefault() method do?

A

Cancels the event if its cancelable

68
Q

What does submitting a form without event.preventDefault() do?

A

Submits it back to the page

69
Q

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

A

Value property

70
Q

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

A

You can have an error in your code and you will have to dig to see what is wrong with it.

71
Q

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

A

Its useful to see if you are getting error messages