JavaScript Concepts Flashcards

1
Q

What data type is returned by an arithmetic operation?

A

Number

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

What is string concatenation?

A

its when you combine strings using the + operator

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

What purpose(s) does the + plus operator serve in JavaScript?

A

for numbers, it acts as the addition operator. 2+ 3 = 5

for strings, it acts as a concatenator

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

What data type is returned by comparing two values < , > , === , etc )?

A

boolean, either true or false

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

What does the += “plus-equals” operator do?

A

it is a shortcut command.

if word += 5 is the same as word = word + 5

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

What is the purpose of variables?

A

to assign a value for later reference. var area = 3 * 2

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

How do you declare a variable?

A

by using the keywords var , let , const

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

How do you initialize (assign a value to) a variable?

A

by using the = sign

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

What does it mean to say that variable names are “case sensitive”?

A

if the cases in the variable name are not matched exactly, an error will show

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

What does the = operator mean in JavaScript?

A

it is used to set values of variables

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

How do you update the value of a variable?

A

by using the variable name then the equal sign, followed by new value

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

What are objects used for?

A

a collection of properties where those properties can have their own values

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

What are object properties?

A

they are variable names that are attached to the object and they can have their values. The values can be different types but the properties are strings.

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

Describe object literal notation.

A
var obj = {
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you remove a property from an object?

A

delete nameOfObject.PropertyToDelete

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

What are the two ways to get or update the value of a property?

A

dot notation or bracket notation

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

What data type is returned by an arithmetic operation?

A

Numbers, including NaN since its type is number

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

What is string concatenation?

A

when you condense 2 or more strings into 1 string using the + operator

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

What purpose(s) does the + plus operator serve in JavaScript?

A

for strings it will be used to concatenate
for numbers it is used to add
for string + number it will concatenate by turning the number into a string

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

What is a function in JavaScript?

A

a formula, can be customized by you to take 0, 1, or more arguments. It will return a value., if you do not use return it will return undefined

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

Describe the parts of a function definition.

A

function key word, function name, parenthesis, and parameters (optional)

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

Describe the parts of a function call.

A
function name followed by (arguments here)
example.  greet('tom')
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

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

A

function definition is just the code that you wrote, it will not run until it is called with ()

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

What is the difference between a parameter and an argument?

A

parameters are used when a function is declared. argument are the values that are passed into the parameters when the function is called

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

Why are function parameters useful?

A

you can use them as variables, which gives way more flexibility to do stuff

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

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

A

1) it ENDS the function when the JS engine finishes the return statement line
2) it returns a value from the function

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

What are arrays used for?

A

to have a collection of data by an ordered list, starting at index 0

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

Describe array literal notation

A

var = [] empty brackets mean array literal

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

How are arrays different from “plain” objects?

A

arrays do NOT have a property name and value. They have an index and a value. But like object, the value can be any type aka functions, objects, another array, number, string, etc

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

What number represents the first index of an array?

A

0

31
Q

What is the length property of an array?

A

how many items it contains = the length

32
Q

How do you calculate the last index of an array?

A

by using arrayName.length - 1

33
Q

Why do we log things to the console?

A

to check our work during development phase

34
Q

What is a method?

A

a function attached to an object as a property

35
Q

How is a method different from any other function?

A

you must call it by calling the object first, using dot notation

36
Q

How do you remove the last element from an array?

A

the pop method

37
Q

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

A

use Math.floor(number here)

38
Q

How do you generate a random number?

A

Math.random(numbers here) it is only from 0-.999999999999999999999

39
Q

How do you delete an element from an array?

A

use the splice method, it is the 2nd argument

40
Q

How do you append an element to an array?

A

by using splice or push

41
Q

How do you break a string up into an array?

A

the split method

42
Q

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

A

no they do not, you can console.log the original variable assigned the the original string to check

43
Q

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

A

40

44
Q

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

A

most of the time yes

45
Q

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

A

about 35

46
Q

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

A

MDN

47
Q

Give 6 examples of comparison operators.

A
< 
 >
==
===
> =
< =
48
Q

What data type do comparison expressions evaluate to?

A

boolean so either true or false

49
Q

What is the purpose of an if statement?

A

to check conditions

50
Q

Is else required in order to use an if statement?

A

no

51
Q

Describe the syntax (structure) of an if statement.

A

if ( condition here ) {
code here
}

52
Q

What are the three logical operators?

A

&& (and) || (or) ! (not)

53
Q

How do you compare two different expressions in the same condition?

A

use either && or ||

54
Q

What is the purpose of a loop?

A

to check values of collection 1 by 1, you can do something during those checks

55
Q

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

A

the parameters for when the loop stops/runs

56
Q

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

A

cycling through each element/value

57
Q

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

A

at the start of the loop

58
Q

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

A

at the start of the loop

59
Q

When does the condition expression of a for loop get evaluated

A

after initialization

60
Q

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

A

after the condition has ran

61
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

62
Q

What does the ++ increment operator do?

A

increases the value of the variable attached by 1

63
Q

How do you iterate through the keys of an object?

A

by using the for in loop

64
Q

What is a method?

A

a function inside an obj

65
Q

How can you tell the difference between a method definition and a method call?

A

definition is when it is being defined inside the function. A method call is requires dot notation to access the method inside the function

66
Q

Describe method definition syntax (structure).

A

propertyName : function name( parameters) {
code block
}

67
Q

Describe method call syntax (structure).

A

objName.Propertyname.methodName( )

68
Q

How is a method different from any other function?

A

it is part of an object

69
Q

What is the defining characteristic of Object-Oriented Programming?

A

writing procedural functions and storing them inside objects, which can then be accessed via dot notation

70
Q

What are the four “principles” of Object-Oriented Programming?

A

Abstraction
Encapsulation
Inheritance
Polymorphism

71
Q

What is “abstraction”?

A

being able to work with (possibly) complex things in simple ways

72
Q

What does API stand for?

A

Application Programming Interface

73
Q

What is the purpose of an API?

A

is a set of functions that allows applications to access data and interact with external software components, operating systems, or microservices