Javascript Flashcards

1
Q

What is purpose of variables

A

To assign a value to them

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

How do you declare a variable

A

var variable;

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

var variable = ‘value’

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

What caracters are allowed in variable names?

A

numbers and some signs $

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

variable is different from Variable they can have two different values

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

to store and pass around a series of characters, so text

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

Math and quantities

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 and False decision making

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

It gives value to a variable

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 it a new 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

It’s intentional to put null

null always needs to be assigned a value whereas undefined wasn’t assigned anything

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

Gives us a point of reference

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, null, and undefined

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

What are objects used for?

A

Place to store multiple values

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

What are object properties?

A

pieces of data glued onto an object

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

Describe object litertal notation

A

The syntax to create an object

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

How do you remove a property from an object?

A

using the operator delete

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

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

A

using dot notation or bracket notation

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

What are arrays used for?

A

To store value inside at specific indexs

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

Describe array literal notation

A

var something = []; and each value is separated by a comma

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

How are arrays different from “plain” objects?

A

0

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

What is the length property of an array?

A

Tells us how many items are in the array

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

How do you calculate the last index of an array?

A

length - 1 and you’ll be able to get the final index

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

What is a function in JavaScript?

A

A set of instructions that is repeatable

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

Describe the parts of a function definition.

A
function name(parameter){
parameter must be present;
return value;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

Describe the parts of a function call

A

console.log(nameOfFunction(arguments));

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

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

A
Calling is utilizing the function and the defining it is making the expression that you want it to
function key word is the most notable difference between the two
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What is the difference between a parameter and an argument

A

a parameter is a variable that is needed for the function to run, an argument is passing a value to that function to allow it to work with that value

29
Q

Why are function parameters useful

A

allows to use different values

30
Q

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

A

ends the function

doesn’t allow any other value to pass

31
Q

What data type is returned by an arithmetic operation

A

A number

32
Q

What is string concatenation?

A

The value of two strings being added together

33
Q

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

A

To concatenates strings and arithmetic

34
Q

What data type is returned by comparing two values (, ===, etc)

A

boolean

35
Q

What does the += operator do?

A

take the current value and add the value inside the operator to make a new value for that variable

36
Q

Why do we log things to the console?

A

To debug or to check things are accurate

37
Q

What is a method?

A

a function that does something specific of an object

38
Q

How is a method different from any other function?

A

method needs to be called with a ‘.’ functions are free floating

39
Q

How do you remove the last element from an array?

A

.pop removes from the end

40
Q

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

A

Math.floor

41
Q

How do you generate a random number?

A

Math.random();
starts off 0 inclusive 1 exclusive
Math.random * 50; makes it 0 - 50;
Math

42
Q

How do you delete an element from an array?

A

.shift end .pop beginning .splice area of

43
Q

How do you append an element to the array?

A

.push

44
Q

How do you break a spring up into an array?

A

.split

45
Q

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

A

Strings are immutable can be edited but cannot be changed. Try it, return the result of the string, or check mdn

46
Q

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

A

A lot

47
Q

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

A

No

48
Q

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

A

A lot

49
Q

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

A

MDN

50
Q

Give 6 Examples of comparison operators

A

> < <= >= === ==

51
Q

What data type do comparison expressions evaluate to?

A

boolean

52
Q

What is the purpose of an if statement?

A

decision making

53
Q

Is else required in order to use an if statement

A

no

54
Q

Describe the syntax structure of an if state

A

if(condition statement) {
what happens if condition is met
}

55
Q

What are the three logical operators?

A

&& || !

56
Q

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

A

Using the logical && or || operator

57
Q

WHat is JSON?

A

A way to transfer fdata overa network of Javascript

stands for javascript object notation

58
Q

What are serializiation and deserialization

A

putting data in a pointer system rather than in order

59
Q

What is a code block? What are some examples of a code block?

A

A code block is block of code within curly braces. A code within a function is considered a function code block
code within a for loop is referred to as a loop code block

60
Q

What does block scope mean?

A

the block is delimited by a pair of curly brackets

61
Q

What is the scope of a variable declared with const or let?

A

a block scope

62
Q

What is the difference between let and const

A

let can be reassigned and const is permanent and not able to be reassigned, however you can add to it. So, let’s say you have a const array. Values can still be pushed into the array they just cannot be changed

63
Q

Why is it possible to push() a new value into a const variable that points to an Array

A

We’re not reassigning the array, we’re mutating

64
Q

How should you decide on which type of declaration to use?

A

If you need a value that cannot change const should be used, if you need to reassign value to a variable then you should use let.

65
Q

What is the syntax for writing a template literal

A

something something something ${variable or function}

66
Q

What is string interpolation

A

To substitute values from a string for the values of variables or expressions

67
Q

What is the syntax for defining an arrow function?

A

() => a - b;
() => { return a - b}
(param1, param2) => a - b;
(param1, param2) => { return a - b }

68
Q

When an arrow function’s body is left without curly braces, what changes in its functionality?

A

You don’t need a return statement

69
Q

How is the value of this determined within an arrow function

A

The arrow function retains the value of the this
In normal functions this is assigned at the value of call time
In arrow function this is being assigned at the time of definition