Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Whether you are a complete beginner or you have some knowledge of JavaScript, this course will guide you from the basics of the language to all the new features introduced up until 2021. You’ll test your knowledge with quizzes and some coding challenges at the end of each chapter.
After following this course, the functions and variables let, const, generators, promises and async won’t be a problem anymore.
If you want to experience something new, this course also includes an introduction to the basics of TypeScript, which is a must-know for any JavaScript developer.
Q1. Which of the following ways of naming a variable is wrong?
var very_important = "very_important"
var important_999 = "important_999"
var important! = "important!"
var VeRY_ImP_orTant = "VeRY_ImP_orTant"
Q2. Which one of the following is not a real Primitive?
symbol
boolean
null
Object
Q3. What is the correct way of defining an Object
?
const car: { color: "red"}
const car = {color = "red"}
const car = { color: "red" }
const car: {color = "red"}
Q4. What is the correct output of the following code?
const obj1 = {a: 1};
const obj2 = {a: 1};
console.log(obj1 === obj2);
undefined
null
Q5. What is the correct output of the following code?
const fruitBasket = ['apple','banana','orange'];
fruitBasket.unshift('melon')
console.log(fruitBasket);
["apple", "banana", "orange", "melon"]
["melon"]
["apple", "banana", "orange", "pear", "melon"]
["melon", "apple", "banana", "orange"]
Q1. What is the correct output of the following code?
var greeting = "Hello";
greeting = "Farewell";
for (var i = 0; i < 2; i++) {
var greeting = "Good morning";
}
console.log(greeting);
Q2. What is the correct output of the following code?
let value = 1;
if(true) {
let value = 2;
console.log(value);
}
value = 3;
Q3. What is the correct output of the following code?
let x = 100;
if (x > 50) {
let x = 10;
}
console.log(x);
Q4. What is the correct output of the following code?
console.log(constant);
const constant = 1;
Q1.What is the correct syntax for an arrow function?
let arr = [1,2,3];
let func = arr.map(n -> n+1);
let func = arr.map(n => n+1);
let func = arr.map(n ~> n+1);
Q2. What is the correct output of the following code?
const person = {
age: 10,
grow: () => {
this.age++;
},
}
person.grow();
console.log(person.age);
Q1. What is the correct output of the following code?
var b = 3;
function multiply(a,b=2){
return a * b;
}
console.log(multiply(5));
Q1. What is the correct output of the following code?
const code = "ABCDEFGHI";
code.startsWith("DEF",3);
Q2. What is the correct output of the following code?
const code = "ABCDEF";
code.endsWith("def");
Q1. Which one of these loops was introduced in ES6?
while
for of
for in
Q2. What is the correct output of the following code?
let people = [ "Tom", "Jerry", "Mickey" ];
for (let person of people){
console.log(person);
}
Q1. What is the correct output of the following code: Array.from([1, 2, 3], x => x * x);
Q2. What is the correct output of the following code?
const array = [1,2,3,4,5,6,1,2,3,1];
let arraySome = array.some( e => e > 2);
console.log(arraySome);
Q3. What is the correct output of the following code?
const array = [1,2,3,4,5];
let found = array.find( e => e > 3 );
console.log(found);
Q1. What is the correct syntax to spread the values of an array?
Q2. What is the correct output of the following code?
let arr = [ 1, 2, 3, 4];
let arr2 = arr;
arr2.push(5);
console.log(arr);
Q1. What is the correct output of this code:
const name = "myname";
const person = {
[name]:"Alberto",
};
console.log(person.myname);
Q2. What is correct output of the following code:
const name = "myname";
const age = 27;
const favoriteColor = "Green";
const person = {
name,
age,
color
};
console.log(person.color);
color is not defined
Q1. What is a symbol
?
Q2. What is the main characteristic of a symbol
?
for loop
Q3. What is the correct output of the following code?
const friends = {
"Tom" : "bff",
"Jim" : "brother",
"Tom" : "cousin",
}
for (friend in friends){
console.log(friend);
}
Q4. What is the correct output of the following code?
const family = {
[Symbol("Tom")] : "father",
[Symbol("Jane")] : "mother",
[Symbol("Tom")] : "brother",
};
const symbols = Object.getOwnPropertySymbols(family);
console.log(symbols);
Q1. What is a class
?
Q2. How can you create a class
? Select all that apply
Q3. What is a static
method?
class
class
itselfQ4. What is the correct output of the following code?
class Person {
constructor(name,age){
this.name = name;
this.age = age;
}
}
class Adult extends Person {
constructor(work){
this.work = work;
}
}
const my = new Adult('software developer');
console.log(my.work);
Q1. What is a Promise
?
Q2. Which of the following promise methods does not exist?
Promise.race()
Promise.some()
Promise.all()
Promise.reject()
Q3. What is the correct output of the following code:
function myPromise(){
return new Promise((resolve,reject) => {
reject();
})
}
myPromise()
.then(() => {
console.log('1')
})
.then(() => {
console.log('2')
})
.catch(() => {
console.log('3')
})
.then(() => {
console.log('4')
});
Q1. What is the correct syntax of a generator function?
generator function() {...}
new generator(){...}
function*(){...}
Q2. What is the main feature of a generator?
Q3. What is the last output of the following code?
function* fruitList(){
yield 'Banana';
yield 'Apple';
yield 'Pomelo';
yield 'Mangosteen';
yield 'Orange';
}
const fruits = fruitList();
fruits;
fruits.next();
fruits.next();
fruits.next();
Object { value: "Banana", done: false }
Object { value: "Pomelo", done: true }
Object { value: "Mangosteen", done: false }
Object { value: "Pomelo", done: false }
Q4. What is the correct output of the following code?
function* fruitList(){
yield 'Banana';
yield 'Apple';
yield 'Orange';
}
const fruits = fruitList();
fruits.return();
Object { value: "Banana", done: true }
Object { value: "Banana", done: true }
Object { value: "Banana", done: false }
Object { value: undefined, done: true }
Q1. What is the use of a Proxy
?
Q2. How many parameters can a Proxy
take?
Q3. Which of the following is correct:
Proxy
must be an ArrayProxy
must not be an ArrayProxy
can be another Proxy
Proxy
cannot be another Proxy
Q1. Which one of these does not exist?
Set
WeakSet
StrongSet
WeakMap
Q2. Which one of the following definition is correct?
Set
can only store objectsWeakSet
can only store objectsWeakSet
can be overwrittenSet
and WeakSet
can only store objectsQ3. Which one of the following definition is correct?
Map
only stores keysSet
stores both keys and values, a Map
only valuesMap
stores both keys and values, a Set
only valuesQ1. What new array method was introduced in ES2016?
Array.prototype.contains()
Array.prototype.includes()
Array.prototype.find()
Q2. What is the correct output of the following code?
let array = [1,3,5,7,9,11];
array.includes(5,4);
Q1. What is the correct output of the following code?
"hello".padStart(6);
Q2. Which of the following was not added in ES2016?
Object.entries()
Object.keys()
Object.values()
Q3. What is the correct ouput of the following code:
const buffer = new SharedArrayBuffer(16);
const uint8 = new Uint8Array(buffer);
uint8[0] = 10;
console.log(Atomics.add(uint8, 0, 5));
Q4. What is the correct output of the following code:
const buffer = new SharedArrayBuffer(16);
const uint8 = new Uint8Array(buffer);
uint8[0] = 10;
Atomics.sub(uint8, 0, 6);
console.log(Atomics.load(uint8,0));
Q1. What is the correct output of the following code?
function func() {
let promise = Promise.resolve(1);
let result = await promise;
}
func();
Q2. What is the last output of the following code:
function walk(amount) {
return new Promise((resolve,reject) => {
if (amount > 500) {
reject ("the value is too big");
}
setTimeout(() => resolve(`you walked for ${amount}ms`),amount);
});
}
async function go() {
const res = await walk(500);
console.log(res);
const res2 = await walk(300);
console.log(res2);
const res3 = await walk(200);
console.log(res3);
const res4 = await walk(700);
console.log(res4);
const res5 = await walk(400);
console.log(res5);
console.log("finished");
}
go();
Q1. What is the correct syntax for the spread operator for objects?
Q2. What is the correct output of the following code:
let myObj = {
a:1,
b:2,
c:3,
d:4,
}
let { a, b, ...z } = myObj;
console.log(z);
[3,4]
{c:3, d:4}
undefined
[c,d]
Q3. What is the correct output of the following code:
const myPromise = new Promise((resolve,reject) => {
resolve();
})
myPromise
.then( () => {
return '1';
})
.finally(()=> {
return '2!';
})
.then( res => {
console.log(res);
})
Q1. What is the correct output of the following code?
const me = Symbol("Alberto");
console.log(me.description);
Symbol
Symbol(Alberto)
undefined
Q2. What is the correct output of the following code?
const letters = ['a', 'b', ['c', 'd', ['e', 'f']]];
console.log(letters.flat())
['a', 'b', ['c', 'd', ['e', 'f']]]
['a', 'b', 'c', 'd', 'e', 'f']
['a', 'b', 'c', 'd', ['e', 'f']]
['a', 'b', ['c', 'd', 'e', 'f']]
Q3. What is the correct output of the following code?
function sum(a, b) { return a + b }
console.log(sum.toString());
function sum(a, b) { return a + b; }
Q1. What is the correct output of the following code?
let bigInt = 99999999999999999;
console.log(bigInt + 1n);
Q2. What is the correct output of the following code?
const user = {
name: 'Alberto',
age: 27,
work: {
title: 'software developer'
}
}
const res = user?.work?.location ? user?.work?.location : user?.work?.title
console.log(res);
Q3. What is the correct output of the following code?
const x = 0;
const res = x ?? 'zero';
console.log(res);
Q4. What is the correct output of the following code?
const x = undefined;
const res = x ?? 'undefined value';
console.log(res);
Q5. What does the globalThis
object reference in a browser environment?
window
document
global
self
Q1. Which one of the following methods was introduced in ES2021
String.prototype.replace()
String.prototype.startsWith()
String.prototype.replaceAll()
String.prototype.substring()
Q2. Which one of the following methods were introduced in ES2021?
Promise.race()
Promise.every()
Promise.any()
Promise.all()
Q3. What is the correct output of the following code?
new Intl.ListFormat("en-GB", { style: "long", type: "conjunction" }).format(
list
)
Q4. What is the correct output of this code?
new Intl.DateTimeFormat("en", {
dateStyle: "short",
}).format(Date.now());
Q1. What is the character used to define private methods in ES2022?
private
@
#
*
Q2. Which one of these is valid for static
methods?
class
private
class
Q3. What is the new character used in RegExp to match indices?
Q4. What is the correct output of the following code?
const arr = [10,20,30,40];
console.log(arr.at(-2));
Q5. What is the correct output of the following code?
const student = {
age:10;
hasOwnProperty: () => {
console.log(false)
}
}
student.hasOwnProperty('age');
Q1. Which one of these is not a real basic type of TypeScript
?
Q2. What is the correct type of the following variable?
const x = 0xf00d;
string
void
hex
number
Q3. Which of the following type definition is wrong?
const firstArray: number[] = [1,2,3]
const firstArray: Array<number> = [1,2,3]
const firstArray: number<Array> = [1,2,3]
Q4. What is the correct output of the following code?
enum Rank {first, second, third}
const myRank: Rank = Rank.second;
console.log(myRank);
{second:1}
Q5. What is the correct way of defining an Interface
?
interface Car = { wheels: number }
interface Car { wheels = number }
interface Car { wheels: number }
interface Car = { wheels = number }
I hope this The Complete Guide to Modern JavaScript Educative Quiz Answers would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
Keep Learning!
More Coding Solutions >>