javascript Flashcards

1
Q

What is the purpose of variables?

A

Store data and information.

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

How do you declare a variable?

A

Start with a variable keyword, followed by the variable name and followed by a semicolon.

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

use an assignment operator (=)

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-z(case sensitive), _(underscore), dollar sign, camel case, numbers.

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

App vs app means two 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

Store text data and They are frequently used to add
new content into a page and they
can contain HTML markup.

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
Calculating.  determining the size of the
screen, moving the position of
an element on a page, or setting
the amount of time an element
should take to fade in.
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

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

assign the 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

assign another value?

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 an assigned value, undefined means there is a declared available but not defined.

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

It will be easier to locate the data you are looking for.

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

Give five examples of JavaScript primitives.

A

string, number, boolean, undefined, and null.

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

What are objects used for?

A

store data

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

What are arrays used for?

A

store a collection of data such as lists

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

What is the length property of an array?

A

the name of the array.length

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

What is a function in JavaScript?

A

A block of code that can be stored and reused.

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

What is the difference between a parameter and an argument?

A

the parameter is the name and the argument is the real value.

20
Q

Why are function parameters useful?

A

It can store different types of data.

21
Q

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

A

no code will be run after the return statement.

22
Q

Why do we log things to the console?

A

Console log provides you data and checks things work correctly.

23
Q

What is a method?

A

is a function?

24
Q

How is a method different from any other function?

A

need to look up.

25
How do you remove the last element from an array?
pop()
26
How do you round a number down to the nearest integer?
math.floor()
27
How do you generate a random number?
math.random()
28
How do you delete an element from an array?
splice()
29
How do you append an element to an array?
push(), unshift()
30
How do you break a string up into an array?
split(" ")
31
Do string methods change the original string? How would you check if you weren't sure?
You cannot change the original string.
32
Roughly how many string methods are there according to the MDN Web docs?
roughly 30 methods.
33
Is the return value of a function or method useful in every situation?
They are not always useful. Sometimes the return value does not give you much information.
34
Roughly how many array methods are there according to the MDN Web docs?
a lot of them
35
What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?
MDN
36
Why do we log things to the console?
To test the code runs properly.
37
What is a "model"?
?
38
Which "document" is being referred to in the phrase Document Object Model?
html?
39
What is the word "object" referring to in the phrase Document Object Model?
elements in the html
40
What is a DOM Tree?
The structure of the html?
41
Give two examples of document methods that retrieve a single element from the DOM.
queryselector()
42
Give one example of a document method that retrieves multiple elements from the DOM at once.
queryselectorAll()
43
Why might you want to assign the return value of a DOM query to a variable?
easily to locate?
44
What console method allows you to inspect the properties of a DOM element object?
console.dir()
45
Why would a tag need to be placed at the bottom of the HTML content instead of at the top?
The browser needs to parse all of the elements in the HTML page before the JavaScript code can access them.
46
What does document.querySelector() take as its argument and what does it return?
CSS selector.