Variables & Types Flashcards

1
Q

What is a template literal?

A

string literals allowing embedded expressions

i.e. string text ${expression} string text

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

What does string.raw() do?

A

It takes the complete string of a template literal and renders it raw, including any escaped or special characters.

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

What is the difference between let and const?

A
  • Both are block scoped and you will receive a ReferenceError when accessing a variable before it’s declared
  • Let can be reassigned while const cannot
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the difference between let and var?

A
  • let is block scoped while var is global / function scoped
  • referencing var before it is defined will result in ‘undefined’
  • referencing let before its defined with result in a ReferenceError.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the startsWith() method?

A
  • The startsWith() method determines whether a string begins with the characters of a specified string.
  • Method is case sensitive
  • Returns a boolean value.

string.startsWith (searchvalue, start) –> The start value is optional. If not specified, it starts at the beginning of the string. If specified, it will start at the index specified.

Example:

var str = “Hello world, welcome to the universe.”;

var n = str.startsWith(“world”, 6); returns true

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

What is the ends with() method?

A
  • Determines whether a string ends with the characters of a specified string.
  • Case sensitive
  • returns a boolean value

Syntax: string.endsWith(searchvalue, length)

where length is optional. It specified the length of the string to search from the start of the string.

var str = "Hello world, welcome to the universe.";
var n = str.endsWith("world", 11); **returns true**
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is an example of a correct destructuring syntax for deconstructing an array?

A

var [Id, ApplicantName] = arr;

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

T/F: A template literal always has more strings than values

A

True

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

What is a Symbol in JavaScript?

A
  • primitive data type
  • the Symbol() function returns a value of type symbol
  • A symbol value may be used as an identifier for object properties
  • A globally unique, un-guessable value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does Number.isSafeInteger(value) do?

A

Test if the value is and integer and falls between MIN_SAFE_INTEGER and MAX_SAFE_INTEGER

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