JavaScript Flashcards

1
Q

What is the purpose of variables?

A

A variable is a way to store values.

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

How do you declare a variable?

A

Use the reserved keyword var to declare a variable in JavaScript. Syntax: var ; var = ; A variable must have a unique name.

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

You can assign a value to a variable using the = operator when you declare it or after the declaration and before accessing it

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

Start them with a letter, underscore _, or dollar sign $.
After the first letter, you can use numbers, as well as letters, underscores, or dollar signs.
Don’t use any of JavaScript’s reserved keywords.

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

means that language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters.

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 represent text rather than numbers

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

to represent and manipulate numbers

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

to create true/false statements

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

assigns a value to its left operand based on the value of its right operand.

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

What is the difference between null and undefined

A

undefined is a type, whereas null an object

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

Give five examples of JavaScript primitives.

A

undefined , null , boolean , string and number

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

What data type is returned by an arithmetic operation?

A

numeric data

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

What is string concatenation?

A

Concatenation is the process of appending one string to the end of another string

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

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

A

precedes its operand and evaluates to its operand but attempts to convert it into a number, if it isn’t already

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

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

A

boolean

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

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

A

adds the value on the right, to the variable on the left, and then assigns that value back into the variable on the left.

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

What is object used for?

A

An object is an abstract data type with the addition of polymorphism and inheritance.

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

What are object properties?

A

Object properties are defined as a simple association between name and value

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

Describe object literal notation.

A

The Object literal notation is basically an array of key:value pairs, with a colon separating the keys and values, and a comma after every key:value pair, except for the last, just like a regular array

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

How do you remove a property from an object?

A

delete operator

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

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

A

dot notation and square brackets

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

What are arrays used for?

A

to store a collection of data

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

Describe array literal notation.

A

array literal notation is where you define a new array using just empty brackets.

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

How are arrays different from “plain” objects?

A

object store different types of data, dont have orders. array store same types of data, have orders.

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

What is the length property of an array?

A

how many pieces in the array

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

How do you calculate the last index of an array?

A

array.length-1

28
Q

What is a function in JavaScript?

A

a set of statements that performs a task or calculates a value

29
Q

Describe the parts of a function definition.

A

A function has three parts, a set of inputs, a set of outputs, and a rule that relates the elements of the set of inputs to the elements of the set of outputs in such a way that each input is assigned exactly one output.

30
Q

Describe the parts of a function call.

A

Function calls contain the name of the function being executed followed by a list of values, called arguments, which are assigned to the parameters in the function definition

31
Q

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

A

A function is a piece of code which enhanced the reusability and modularity of your program. It means that piece of code need not be written again. A function call means invoking or calling that function. Unless a function is called there is no use of that function.

32
Q

What is the difference between a parameter and an argument?

A

The values that are declared within a function when the function is called are known as an argument. Whereas, the variables that are defined when the function is declared are known as a parameter.

33
Q

Why are function parameters useful?

A

Parameters allow us to pass information or instructions into functions and procedures .

34
Q

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

A

A return statement ends the execution of a function, and returns control to the calling function.

35
Q

Why do we log things to the console?

A

console. log specifically is a method for developers to write code to inconspicuously inform the developers what the code is doing

36
Q

What is a method?

A

A JavaScript method is a property of an object that contains a function definition.

37
Q

How is a method different from any other function?

A

a method is associated with an object, while a function is not

38
Q

How do you remove the last element from an array?

A

pop()

39
Q

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

A

floor()

40
Q

How do you generate a random number?

A

random()

41
Q

How do you delete an element from an array?

A

splice()

42
Q

How do you append an element to an array?

A

push() to the end; unshift() to the beginning

43
Q

How do you break a string up into an array?

A

split()

44
Q

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

A

no, console.log origin string out

45
Q

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

A

MDN

46
Q

Give 6 examples of comparison operators

A

> ,=,<=,!=,===

47
Q

What data type do comparison expressions evaluate to?

A

bolean

48
Q

What is the purpose of an if statement?

A

The IF statement is a decision-making statement that guides a program to make decisions based on specified criteria

49
Q

Is else required in order to use an if statement?

A

else is compulsory to use with if statement.

50
Q

What are the three logical operators?

A

and , or, not

51
Q

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

A

and or or

52
Q

What is the purpose of a loop?

A

Loops allow you to repeat a process over and over without having to write the same (potentially long) instructions each time you want your program to perform a task.

53
Q

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

A

tell loop when to stop

54
Q

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

A

Iteration is the repetition of a process in a computer program, usually done with the help of loops.

55
Q

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

A

before executing the statement.

56
Q

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

A

before the loop begin

57
Q

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

A

at the end of each loop iteration

58
Q

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

A

at the end of the loop iteration

59
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;

60
Q

How do you iterate through the keys of an object?

A

for in loop

61
Q

What is the className property of element objects

A

to set or return the value of an element’s class attribute

62
Q

How do you update the CSS class attribute of an element using JavaScript

A

use queryselector to select the query then use className to change

63
Q

What is the textContent property of element objects?

A

The textContent property returns: The text content of the element and all descendaces, with spacing and CSS hidden text, but without tags

64
Q

How do you update the text within an element using JavaScript?

A

use queryselector to select the query then use textContent to change

65
Q

What is a client?

A

a desktop computer or workstation that is capable of obtaining information and applications from a server.

66
Q

what is a server

A

a server is a piece of computer hardware or software that provides functionality for other programs or devices,
A server stores, sends, and receives data