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

A

.length

19
Q

Is equal to

A

===

20
Q

or operator

A

||

Checked FIRST || LAST

21
Q

truthy or falsy?

Empty strings like “” or ‘’

A

falsy

22
Q

truthy or falsy?

‘Elliott’

A

Truthy.

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
Q

Proper order?
A. else (){} if (){} else if
B. if (){} else (){} else if
C. if (){} else if (){} else

A

if / else if / else

26
Q

what is a switch statement

A

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
Q

break

A

tells the computer to exit the block and not execute any more code or check any other cases inside the code block.

28
Q

default

A

at the end of a switch statement, is the default outcome if all else fails.

29
Q

What will a switch statement do without a break?

A

the first matching case will run, but so will every subsequent case regardless of whether or not it matches—including the default.

30
Q

Bang operator

A

The bang operator, !, switches the truthiness and falsiness of a value.

31
Q

Strict inequality operator

A

!==

checks whether its two operands are not equal, returning in a boolean.

32
Q

Control flow

A

order in which statements are executed in a program.

33
Q

what is a condition

A

the enclosing brackets () after a logic statement

34
Q

control flow statements

A

if then else etc

35
Q

function

A

repeatable set of tasks

36
Q

What comes after the function keyword?

A

an identifier

37
Q

What is hoisting?

A

Accessing a function before it is called

38
Q

What is hoisting?

A

Accessing a function before it is defined

39
Q

What is hoisting?

A

Calling a function before it is defined

40
Q

What do parameters do?

A

Parameters allow functions to accept input(s) and perform a task using the input(s).

41
Q

Default parameters

A
function funtionName(parameter = 'Default Value', parameter2 = 100, parameter3  = true) {
 // Function body here
}