Javascript Flash Cards


Resources:

Click on a card to reveal the answer.

What is the syntax for the error.cause subclass?

new Error (
'Something went wrong',
{ cause: otherError }
)

What is a variable?

A variable is a “named storage”
for data.

What expression checks if obj has a private slot #privateSlot?

#privateSlot in obj

What does the syntax of the constructor look like?

constructor( value ){
this.value = value;
}

What is the output of 'abbbaab'.replaceAll('b', 'x')

'axxxaax'

How do you copy an object without referencing to the original object?

let newObject = Object.assign(
 {},
 originalObject
);

What "indexable" types have method .at()

-string
-array
-All Typed Array classes:
 Unit8Array etc.

How do you write a conditional ternary sequence?

let message =
 (age < 3) ? 'Hi, baby!' :
 (age < 18) ? 'Hello!' :
 (age < 100) ? 'Greetings!' :
 'What an unusual age!';

What import expression imports all exports of the module 'mod'?

import * as ns from 'mod'

How do you enable strict mode on JavaScript documents to enable better error tracking?

add 'use strict' to the first line
of the document

What is a callback function?

A callback function is a function
passed into another function
as an argument

What does a Nullish coalescing operator '??' do?

returns the first argument if it's
not null/undefined. Otherwise, the
second one.

How can you get the maximum number in an array

Math.max(...arr);

What are the ECMAScript 2021 assignment operators?

a ||= b
a &&= b
a ??= b

Provate slots are new and can be created via

- Private fields
 (instance and static)
- Private methods and 
accessors
(non-static and static)

What is the sytnax of the constructor if the class is extended from another class?

constructor( value ){
super( value );
}

How do you initiate a prompt?

result = prompt(
 'title',
 'default input'
);

Properties (public slots) can now be created via...

- Instance public fields
- Static public fields

What is the output of ['a', 'b', 'c',].at(-1)

'c'

How do you initiate a confirm?

result = confirm(question);

What is an exampole of optional chaining?

value.?prop

How do you increment prefix and postfix?

prefix: ++a
postfix: b++

What is the function name to pass parameters in a class?

constructor()

Where should 'use strict' be enabled

add 'use strict' to the first line
of the document

What is a transpiler?

A transpiler is a special piece of
software that translates source
code to another source code.