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
Q

How do you remove the last element from an array?

A

pop()

26
Q

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

A

math.floor()

27
Q

How do you generate a random number?

A

math.random()

28
Q

How do you delete an element from an array?

A

splice()

29
Q

How do you append an element to an array?

A

push(), unshift()

30
Q

How do you break a string up into an array?

A

split(“ “)

31
Q

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

A

You cannot change the original string.

32
Q

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

A

roughly 30 methods.

33
Q

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

A

They are not always useful. Sometimes the return value does not give you much information.

34
Q

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

A

a lot of them

35
Q

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

A

MDN

36
Q

Why do we log things to the console?

A

To test the code runs properly.

37
Q

What is a “model”?

A

?

38
Q

Which “document” is being referred to in the phrase Document Object Model?

A

html?

39
Q

What is the word “object” referring to in the phrase Document Object Model?

A

elements in the html

40
Q

What is a DOM Tree?

A

The structure of the html?

41
Q

Give two examples of document methods that retrieve a single element from the DOM.

A

queryselector()

42
Q

Give one example of a document method that retrieves multiple elements from the DOM at once.

A

queryselectorAll()

43
Q

Why might you want to assign the return value of a DOM query to a variable?

A

easily to locate?

44
Q

What console method allows you to inspect the properties of a DOM element object?

A

console.dir()

45
Q

Why would a tag need to be placed at the bottom of the HTML content instead of at the top?

A

The browser needs to parse all of the elements in the HTML page before the JavaScript code can access them.

46
Q

What does document.querySelector() take as its argument and what does it return?

A

CSS selector.