JavaScript Quiz Questions Flashcards

(76 cards)

1
Q

What is a variable?

A

A container for storing data

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

Why are variables useful?

A

You can reuse them, assign value to them, use for dynamic operations

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

What two special characters can a variable begin with?

A

A $sign or _underscore

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

How do you declare a variable?

A

The ‘var’ keyword

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

How do you assign a value to a variable?

A

with the equals sign

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

Are variables case sensitive?

A

Yes

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

Which words cannot be used as variable names?

A

other keywords in JS

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

What is a string?

A

A series of characters stored within a pair of “” marks

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

What is the string concatenation operator?

A

+ sign

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

What is the difference when it comes to using single quotes or double quotes ( ‘ ‘ or “ “ )?

A

No difference, but you can use apostrophes in “ “ double quotes.

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

How do you escape quotation characters?

A

With a backslash

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

What is type coercion?

A

The process of converting one data type value to another

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

What is a number in JavaScript?

A

a primitive datatype

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

What is an arithmetic operator?

A

operators that do math

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

Name four of the arithmetic operators?

A

+, -, *, /, %

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

What is the order of execution?

A

PEMDAS

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

What is a boolean?

A

A datatype with the values of true or false

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

What is a comparison operator?

A

Compares two values and returns a true or false value

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

What is the difference between undefined and null?

A

Undefined is a variable that has been declared but no value has been assigned.
Null must be assigned and is an empty value.

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

What advantages do you see with using a grid system?

A

Eliminates a lot of repetition, can be saved for later use,

More organized, and segmented.

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

Why are media queries crucial to responsive grid designs?

A

Allows for the page to be viewed on various device sizes so that nothing is cut out or removed due to sizing changes.

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

What is a function?

A

A list of actions to be performed

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

Why are functions useful?

A

Can be reused for multiple purposes, so they save a lot of time

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

How do you call a function?

A

name of the function with () parenthesis

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What are the parts of a function definition?
``` function keyword, function definition (name) (parameters) {code} ```
26
What is the difference between a parameter and an argument?
Parameters are declared when the function is created | Arguments are the data you pass into the function
27
Why is it important to understand truthy and falsy values?
Can be important when using them in conditional statements or in comparisons, in case type coercion is used.
28
Why is the typeof null an object?
it is a bug
29
What is the difference between null and undefined?
Undefined is a declared variable that has not been assigned a value. Null is an assigned empty value. Undefined is a type, null is an object
30
Why do you always use === for comparisons?
because of type coercion, you might get an inaccurate result
31
Why do you want to avoid using == for comparison?
because of type coercion, you might get an inaccurate result
32
Do all if statements require an else statement?
No
33
What is the proper syntax for using the or operator?
if (num1 < num2 || num1 > num2)
34
What is the primary use case for switches?
For comparing multiple 1 on 1 values
35
Does the default case have to be at the bottom of the switch statement?
No, default can be anywhere on the list
36
What happens if there is no break statement between cases?
The switch will continue until the next break statement
37
What is an object in JavaScript?
datatype that can hold a group of other data/functions
38
What is a property in relation to JavaScript objects?
It is the key/value data within an object
39
When should you use bracket notation over dot notation with objects?
If you have a regular property name that has characters not valid as a property name. Or substitution of variable names.
40
How do you remove a property from an object?
delete object.property
41
What is an array in JavaScript?
An object that holds a series of data in a list like structure
42
How do you create an array literal?
var array = [ ];
43
What are the keys for the values inside an array?
index numbers starting from 0
44
Arrays have a property named length. Because arrays have a properties, what other data structure are they similar to?
objects
45
What are some good use cases for using objects inside arrays?
A list of people (with their information) | -List of cars
46
What is the primary advantage to storing your selected elements in a variable?
So you don't have to rewrite a lot of code such as "document.getElementById()". You can store it into a variable instead.
47
Why might you need JavaScript to modify the DOM after the page loads?
Dynamic changes to the page according to user input
48
How can you better prepare when writing HTML for DOM manipulation in your JavaScript code?
Use ID's and classes
49
What are the differences between innertext and textContent?
textContent grabs everything, even values that are not visible. innerText only grabs visible text textContent is much faster
50
What datatype are the values you remove from a text input?
string
51
Why is it so important to be able to dynamically update text?
For usability: to allow users to make changes on the website based on their input
52
What are some of the drawbacks of HTML Event Handler Attributes?
Might make the HTML less clear, by adding javascript, instead of keeping them separate Maybe same reason inline styling is bad, using the function for multiple parts of the code
53
What is the difference between the getElementById() method and the querySelector() method?
getElementById() is more specific and quicker. | querySelector() is more broad, general use, and newer, but slightly slower
54
Who passes in the event object into the handleClick callback function?
The javascript engine passes it
55
Does a callback function require a name?
No, you can use an anonymous function
56
What is the purpose of a loop?
Repeat a set of code for a given number of time
57
Why might there be different kinds of loops?
for loops are for incrementing variable. | while loops are for other cases
58
What is the purpose of a conditional expression as it relates to loops?
Lets the loop know when to end, or how long to continue
59
Could a loop potentially go on forever?
Yes, if the condition is never false
60
Could a loop never start?
Yes, if the condition is already false before the loops begins
61
How does a for loop differ from a while loop?
while loops only have a condition in the declaration; | for loops have the incrementation and variable declaration in the
62
What potential use cases are there for for loops?
incrementing, you know how long the loop will go on for
63
Which pieces of information provided in the parentheses for a for loop are mandatory?
for (Initialization; Condition; Final Expression)
64
What is a for in loop?
A variation of a for loop designed for objects. | iterates through each property of the object
65
How do you target the value of a property in an object.
use bracket notation | ex) object[property]
66
What is the difference between the parentNode and parentElement properties?
All elements are nodes, but not all nodes are elements | parentElement ignores whitespace characters
67
What are two ways to target elements on the DOM?
querySelector() | getElementById()
68
What is another way to add a text node to an element other than using textContent.
createTextNode(text)
69
How do you create a HTML element using vanilla Javascript?
createElement() method
70
Why is using loops and arrays for creating multiple dom elements preferable to creating them one at a time?
Much more efficient, less code to write
71
Why are arrays preferred over objects for the functionality referenced in question 1?
arrays have a length property
72
Why is it important to be able to retrieve and use data from inputs?
Handling user input
73
Why is it dangerous to assume you have the correct data when creating elements?
Users can make typos, or enter incorrect information, or HACKERS
74
How would you alter the game to make the choice from 1 - 500?
.
75
What are the disadvantages of inline styling via JavaScript?
.
76
What things do you have to consider when building a reset game function?
.