01 const event = new CustomEvent (
02//Missing code
03 );
04 obj.dispatchEvent(event);
Which two options could a developer insert at the placeholder in line 02 to achieve this?const pi = 3.1415926;
What is the data type of `pi`?01 let car1 = new Promise((_, reject) =>
02 setTimeout(reject, 2000, 'Car 1 crashed in the race'));
03 let car2 = new Promise(resolve => setTimeout(resolve, 1500, 'Car 2 completed'));
04 let car3 = new Promise(resolve => setTimeout(resolve, 3000, 'Car 3 completed'));
05
06 Promise.race([car1, car2, car3])
07 .then(value => {
08 let result = `${value} the race.`;
09 })
10 .catch(err => {
11 console.log('Race is cancelled.', err);
12 });
What is the value of `result` when `Promise.race` executes?01 let array = [1, 2, 3, 4, 4, 5, 4, 4];
02 for (let i = 0; i < array.length; i++) {
03 if (array[i] === 4) {
04 array.splice(i, 1);
05 i--;
06 }
07 }
What is the value of `array` after the code executes?01 function execute() {
02 return new Promise((resolve, reject) => reject());
03 }
04 let promise = execute();
05
06 promise
07 .then(() => console.log('Resolved1'))
08 .then(() => console.log('Resolved2'))
09 .then(() => console.log('Resolved3'))
10 .catch(() => console.log('Rejected'))
11 .then(() => console.log('Resolved4'));
What is the result when the Promise in the execute function is rejected?01 function myFunction(reassign) {
02 let x = 1;
03 var y = 1;
04
05 if (reassign) {
06 let x = 2;
07 var y = 2;
08 console.log(x);
09 console.log(y);
10 }
11
12 console.log(x);
13 console.log(y);
14 }
What is displayed when `myFunction(true)` is called?let inArray = [[1, 2], [3, 4, 5]];
Which two statements result in the array `[1, 2, 3, 4, 5]`?01 function Monster() {
02 this.name = 'hello';
03 }
04 const x = Monster();
What happens due to the lack of the `new` keyword on line 04?<input type="text" value="Hello" name="input">
<button type="button">Display</button>
The developer wrote the JavaScript code below:
01 const button = document.querySelector('button');
02 button.addEventListener('click', () => {
03 const input = document.querySelector('input');
04 console.log(input.getAttribute('value'));
05 });
When the user clicks the button, the output is always "Hello". What needs to be done to make this code work as expected?01 function changeValue(obj) {
02 obj.value = obj.value / 2;
03 }
04 const objA = { value: 10 };
05 const objB = objA;
06
07 changeValue(objB);
08 const result = objA.value;
What is the value of `result` after the code executes?01 function Car(maxSpeed, color) {
02 this.maxSpeed = maxSpeed;
03 this.color = color;
04 }
05 let carSpeed = document.getElementById('carSpeed');
06 debugger;
07 let fourWheels = new Car(carSpeed.value, 'red');
When the code execution stops at the breakpoint on line 06, which two types of information are available in the browser console?01 let total = 10;
02 const interval = setInterval(() => {
03 total++;
04 clearInterval(interval);
05 total++;
06 }, 1000);
07 total++;
08 console.log(total);
Considering that JavaScript is single-threaded, what is the output of line 08 after the code executes?01 let country = 1;
02
03 get capital() {
04 let city = Number('London');
05 return {
06 citystring: city.toString()
07 };
08 }
Which value can a developer expect when referencing `country.capital.citystring`?