Syntax intro Flashcards

1
Q

What is a template literal?

A

String literal that adds to expressions through interpolation.
Denoted by “ ` “ the backtick.

const myPet = 'armadillo';
console.log(`I own a pet ${myPet}.`);
// Output: I own a pet armadillo.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are template literals wrapped with?

A

Backticks.

`

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

What operator is useful to check the data type of a variable’s value?

A

typeof

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

What are strings wrapped with?

A

Apostrophes.

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

What is the preferred way to declare a variable when it can be reassigned?

A

let

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

What is the preferred way to declare a variable with constant value?

A

const

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

What is the primitive data type of variables that have not been initialized?

A

undefined

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

what operator is used to consecrate strings?

A

+

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

What is a Method?

A

Methods return information about an object, and are called by appending an instance with a period ., the method name, and parentheses.

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

return a floating-point, random number in the range from 0 (inclusive) up to but not including 1.

A

Math.random()

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

return the largest integer less than or equal to the given number.

A

Math.floor()

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

intentional absense of value

A

null

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

Modulo

A

%
finds the remainder
10 % 5

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

single line comment

A

//

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

multi line comment

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

What is faster ABOVE 30 substrings, interpolation or concatenation?

A

Interpolation

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

What is faster BELOW 30 substrings, interpolation or concatenation?

A

Concatenation

CON CAT E NATION

18
Q

method that finds length of a string

19
Q

Is equal to

20
Q

or operator

A

||

Checked FIRST || LAST

21
Q

truthy or falsy?

Empty strings like “” or ‘’

22
Q

truthy or falsy?

‘Elliott’

23
Q

NaN

A

Not a number

24
Q

Ternary operator operators

A

? : ;

isLocked ? console.log(‘You will need a key to open the door.’) :
console.log(‘You will not need a key to open the door.’);

25
Proper order? A. else (){} if (){} else if B. if (){} else (){} else if C. if (){} else if (){} else
if / else if / else
26
what is a switch statement
A switch statement provides an alternative syntax to else if that is easier to read and write. A switch statement looks like this: switch (...) { case '...' : ANYFUNCTION( ); break; ``` case 'lime': console.log('Limes are $1.49'); break; case 'papaya': console.log('Papayas are $1.29'); break; default: console.log('Invalid item'); break; } ```
27
break
tells the computer to exit the block and not execute any more code or check any other cases inside the code block.
28
default
at the end of a switch statement, is the default outcome if all else fails.
29
What will a switch statement do without a break?
the first matching case will run, but so will every subsequent case regardless of whether or not it matches—including the default.
30
Bang operator
The bang operator, !, switches the truthiness and falsiness of a value.
31
Strict inequality operator
!== | checks whether its two operands are not equal, returning in a boolean.
32
Control flow
order in which statements are executed in a program.
33
what is a condition
the enclosing brackets () after a logic statement
34
control flow statements
if then else etc
35
function
repeatable set of tasks
36
What comes after the function keyword?
an identifier
37
What is hoisting?
Accessing a function before it is called
38
What is hoisting?
Accessing a function before it is defined
39
What is hoisting?
Calling a function before it is defined
40
What do parameters do?
Parameters allow functions to accept input(s) and perform a task using the input(s).
41
Default parameters
``` function funtionName(parameter = 'Default Value', parameter2 = 100, parameter3 = true) { // Function body here } ```