Basic Javascript Flashcards

1
Q

What is a variable?

A

container to store data

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

Why are variables useful?

A

as a reference, to go and get that data

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

$ dollar sign and _ 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

= known as the assignment operator or equal 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

function, var, if, else, switch, no numbers at the beginning. Basically keywords

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

What is a string?

A

sub series of characters enclosed by quotes

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

What is the string concatenations operator?

A

the plus 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?

A

nothing

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

How do you escape quotations characters?

A

\ backslash

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

What is type coercion?

A

converting value from one type 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 data type

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

What is an arithmetic operator

A

math function that takes two operands and performs a calculation on them

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) mult and div before add and sub

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

What is a boolean?

A

true or false data type

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

What is a comparison operator?

A

comparing values to each other and resolve to a boolean

19
Q

What is the difference between undefined and null?

A

humans assign null and undefined is accidental

20
Q

What is a function?

A

block of code designed to perform a particular task

21
Q

Why are functions useful?

A

to be more productive

22
Q

How do you call a function?

A

with a parenthesis

23
Q

What are the parts of a function definition?

A

function keyword, parameter list, code block, return

24
Q

What is the difference between a parameter and an argument?

A

parameter is a named variable passed into a function, argument are the actual values passed to the function

25
Why is it important to understand truthy and falsy values?
to check conditionals
26
Why is the typeof an object null?
its a bug
27
What is the difference between null and undefined?
null is an assigned value and undefined means a variable has been declared but not defined yet
28
Why do you always use === for comparisons?
to not allow multiple different types of values or to make it more strict
29
Why do you want to avoid using == for comparison?
to not have variance in the code
30
Do all if statements require an else statement/
NO
31
What is the proper syntax for using the or operator?
|| dual pipes
32
What is the primary use case for switches?
allows a variable to be tested for equality against a list of values
33
Does the default case have to be a at the bottom of the switch statement?
it can be at any place within the switch
34
What happens if there is no break statement between cases?
the program continues to the next labeled statement.
35
What is an object in JS?
unordered collection of related data. a collection of properties and methods linked together
36
How do you create an object literal?
``` var object ={ }; var object = new Object( ); its the same thing ```
37
What is a property in relation to JS objects?
A place in which we store data inside on an object.
38
When should you use bracket notation over dot notation with objects?
bracket notations allows the use of characters that can't be used with dot notation. Also when a property name is a variable
39
How do you remove a property from an object?
the delete operator deletes both the value of the property and the property itself.
40
What is an array?
used to store a collection of data
41
How do you create an array literal?
by using an enclosed square bracket
42
What are the keys for the values inside an array?
numbers counting up from zero
43
Arrays have a property named length. Because arrays have properties, what other data structure are they similar to?
objects
44
What are some good use cases for using objects inside arrays?
to remember the order of a series of objects. anything that involves a list of complex data