option
Cuestiones
ayuda
daypo
buscar.php

JavaScript Developer - Set 4

COMENTARIOS ESTADÍSTICAS RÉCORDS
REALIZAR TEST
Título del Test:
JavaScript Developer - Set 4

Descripción:
Set 4 JavaScript Developer

Fecha de Creación: 2026/10/08

Categoría: Arte

Número Preguntas: 65

Valoración:(0)
COMPARTE EL TEST
Nuevo ComentarioNuevo Comentario
Comentarios
NO HAY REGISTROS
Temario:

Which statement accurately describes an aspect of promises?. .then() cannot be added after a catch. In a .then() function, returning results is not necessary. Arguments for the callback function passed to .then() are optional. .then() manipulates and returns the original promise.

Refer to the following code block: class Animal { makeSound() { console.log(`${this.name} is making a sound.`); } } class Dog extends Animal { makeSound() { console.log(`${this.name} is barking.`); } } let myDog = new Dog('Puppy'); myDog.makeSound(); What is the console output?. Uncaught ReferenceError. Undefined. Puppy is barking. Puppy is making a sound.

What is the data type of pi in `const pi = 3.1415926;`?. Number. Float. Double. Decimal.

What is the return value of msg when getAvailabilityMessage("newUserName") is executed and getAvailability("newUserName") returns false? (Where msg is declared inside the true block but returned outside). "newUserName". "msg is not defined". undefined. "Username available".

What is the value of result when the code executes? function changeValue(param) { param = 5; } let a = 10; let b = a; changeValue(b); const result = a + '-' + b;. 5-5. 5-10. 10-5. 10-10.

Universal Containers recently launched its new landing page. Once fully loaded, it creates more than 50 new HTML items placed randomly inside the DOM with class `ad-library-item`. What can the developer do to temporarily and quickly remove them?. Use the browser console to execute a script that removes all the elements containing the class ad-library-item. Use the DOM inspector to remove all the elements containing the class ad-library-item. Use the browser console to execute a script that prevents the load event to be fired. Use the DOM inspector to prevent the load event to be fired.

A developer found some functions that might cause the website to be slow. To verify this, the developer decides to execute everything and log the time each of these functions consumes. Which function can the developer use to obtain the time spent by every one of the functions without stopping the timer?. console.timeLog(). console.trace(). console.timestamp(). console.getTime().

What is logged to the console? const delay = async delay => { return new Promise((resolve) => { console.log(1); setTimeout(resolve, delay); }); }; const callDelay = async () => { console.log(2); await delay(1000); console.log(3); }; console.log(4); callDelay(); console.log(5);. 4 2 1 3 5. 4 2 1 5 3. 1 4 2 3 5. 4 5 1 2 3.

A developer is setting up a Node.js server and is creating a script at the root. The developer declares a variable that needs the folder location that the code executes from. Which global variable can be used in the script?. __filename. window.location. this.path. __dirname.

Refer to the code below: flag(); function flag() { console.log('flag'); } const anotherFlag = () => { console.log('another flag'); } anotherFlag(); What is the result of the code block?. The console logs only 'flag'. An error is thrown. The console logs 'flag' and then an error is thrown. The console logs 'flag' and 'another flag'.

A developer is creating a simple webpage with a button. The message gets displayed every time a user clicks the button, instead of just the first time. Which two code lines make this code work as required?. On line 04, use button.removeEventListener('click', listen);. On line 02, use event.first to test if it is the first execution. On line 04, use event.stopPropagation();. On line 06, add an option called {once: true} to button.addEventListener().

Refer to the code below: let first = 'Who'; let second = 'What'; try { try { throw new Error('Sad'); } catch(err) { first = 'Why'; throw err; } finally { second = 'When'; } } catch(err) { second = 'Where'; } What are the values for first and second?. first is Who and second is Where. first is Why and second is Where. first is Who and second is When. first is Why and second is When.

A developer needs to test this function sum3. Which two assert statements are valid tests for this function?. console.assert(sum3([1, '2']) == 12);. console.assert(sum3([-3, 2]) === -1);. console.assert(sum3(['hello', 2, 3, 4]) === NaN);. console.assert(sum3([]) === 0);.

Refer to the code below: const searchText = 'Yay! Salesforce is amazing!'; let result1 = searchText.search(/sales/i); let result2 = searchText.search(/sales/); What is displayed on the console?. > 5 > undefined. > 5 > 0. > true > false. > 5 > -1.

A developer is leading the creation of a new web server. The lead developer wants to advocate for a more seasoned back-end framework that already has a community around it. Which two frameworks could the lead developer advocate for?. Angular. Express. Gatsby. Koa.

The developer has a getNextValue function to execute after handleObjectValue(), but does not want to execute getNextValue() if an error occurs. How can the developer change the code to ensure this behavior?. try { handleObjectValue(x); } catch(error) { handleError(error); } then { getNextValue(); }. try { handleObjectValue(x); getNextValue(); } catch(error) { handleError(error); }. try { handleObjectValue(x); } handleError(error) { catch(error); }. try { getNextValue(); handleObjectValue(x); } catch(error) { handleError(error); }.

Considering type coercion, what does the following expression evaluate to? true + '13' + NaN. 'true13NaN'. '113NaN'. 14. 'true13'.

A developer imports a library that creates a web server. The imported library uses events and callbacks to start the server. Which code sets up an event and starts the web server?. server.on('connect', (port) => { console.log('Listening on', port); });. server.start();. server((port) => { console.log('Listening on', port); });. server();.

At Universal Containers, every team has its own way of copying JavaScript objects. What is the output of the code execution when using JSON.stringify(JSON.parse(john)) on an object containing a function?. Hello John Doe. Hello Dan Doe. TypeError: dan.name is not a function. Hello Dan.

A developer needs to dispatch a custom event called update to send information about recordId. Which two options could a developer insert to achieve this?. {type: 'update', recordId: '123abc'}. 'update', { detail: { recordId: '123abc' } }. 'update', '123abc'. 'update', { detail: '123abc' }.

Given the HTML below: <div id="row-as">Applied Shipping</div> Which statement adds the priority-account CSS class to the Applied Shipping row?. document.querySelectorAll('#row-as').classList.add('priority-account');. document.querySelector('#row-as').classList.add('priority-account');. document.querySelector('#row-as').classes.push('priority-account');. document.getElementById('row-as').addClass('priority-account');.

A developer is required to write a function that calculates the sum of elements in an array but is getting undefined every time the code is executed via arr.reduce. Which line replacement makes the code work as expected?. 03 if (arr.length == 0) { return 0; }. 04 result = result + current;. 02 arr.map((result, current) => {. 05 return result + current;.

A developer wants to create a simple image upload in the browser using the File API. Which code allows the user to select an image from their local computer, and to display the image in the browser?. const reader = new File(); if(file) URL.createObjectURL(file);. const reader = new FileReader(); if(file) reader.readAsDataURL(file);. const reader = new FileReader(); if(file) URL.createObjectURL(file);. const reader = new File(); if(file) reader.readAsDataURL(file);.

A developer copied a JavaScript object using Object.assign. The object has a name method defined as an arrow function inside the constructor. How does the developer access dan's firstName and lastName?. dan.firstName() + dan.lastName(). dan.name(). dan.name. dan.firstName + ' ' + dan.lastName.

A developer publishes a new version of a package with bug fixes but no breaking changes. The old version number was 2.1.1. What should the new package version number be based on semantic versioning?. 2.1.2. 2.2.0. 2.2.1. 3.1.1.

A developer wants to use a module named universalContainersLib and then call functions from it. How should a developer import every function from the module and then call the functions foo and bar?. import * as lib from '/path/universalContainersLib.js'; lib.foo(); lib.bar();. import * from '/path/universalContainersLib.js'; universalContainersLib.foo();. import all from '/path/universalContainersLib.js'; universalContainersLib.foo();. import {foo,bar} from '/path/universalContainersLib.js'; foo(); bar();.

Refer to the following object with a getter: `get fullName() { return this.firstName + ' ' + this.lastName; }`. How can a developer access the fullName property for cat?. cat.fullName(). cat.get.fullName. cat.function.fullName(). cat.fullName.

A developer has two ways to write a function: Option A defines it as `this.growl = () => {}` inside the constructor. Option B defines it as `Monster.prototype.growl = () => {}`. After creating 1000 monster objects, how many growl methods are created?. 1000 growl methods are created regardless of which option is used. 1 growl method is created regardless of which option is used. 1000 growl methods are created for Option A. 1 growl method is created for Option B. 1 growl method is created for Option A. 1000 growl methods are created for Option B.

Which code change should be done for the console to log 'Row log' and 'Table log' when 'Click me!' is clicked? (The row has event.stopPropagation() currently). Change line 14 to elem.addEventListener('click', printMessage, true);. Remove lines 13 and 14. Change line 10 to event.stopPropagation(false);. Remove line 10 (event.stopPropagation()).

Given Animal constructor sets `this.type` and `this.canTalk`. Pet constructor calls `Animal.call(this, size, type)` and sets `this.size`, `this.name`, `this.owner`. Which three properties are set directly on the pet1 instance?. speak. owner. canTalk. name. type.

A developer wrote a test for sum3. A different developer changed the behavior to sum ALL numbers in the array. Which two results occur when running the old test (`sum3([1,2,3])===6` and `sum3([1,2,3,4])===6`) on the updated function?. The line 02 assertion fails. The line 05 assertion passes. The line 05 assertion fails. The line 02 assertion passes.

Given the code below: Person.proto = { job: () => 'Developer' }; const myFather = new Person(); const result = myFather.firstName + ' ' + myFather.job(); What is the value of result?. Error: myFather.job is not a function. undefined Developer. John Developer. John undefined.

Given the code below: `setCurrentUrl(); console.log(url); function setCurrentUrl(){ url = window.location.href; }` What happens when the code executes?. The url variable has global scope and line 02 throws an error. The url variable has global scope and line 02 executes correctly. The url variable has local scope and line 02 executes correctly. The url variable has local scope and line 02 throws an error.

Given the requirement to refactor the vehicle prototype code to JavaScript class format, which class definition is correct?. class Vehicle { constructor(name, price) { this.name = name; this.price = price; } priceInfo() { return `Cost...`; } }. class Vehicle { vehicle(name, price) { this.name = name; this.price = price; } priceInfo() { return `Cost...`; } }. class Vehicle { constructor() { this.name = name; this.price = price; } priceInfo() { return `Cost...`; } }. class Vehicle { constructor(name, price) { this.name = name; this.price = price; } function priceInfo() { return `Cost...`; } }.

Which statement allows a developer to update the browser navigation history without a page refresh?. window.customHistory.pushState(newStateObject, "null");. window.history.createState(newStateObject, "");. window.history.pushState(newStateObject, "null", url);. window.history.updateState(newStateObject, "");.

Which three console logging methods allow the use of string substitution ('%s')?. message. log. assert. info. error.

A developer has a module that contains multiple functions. What kind of export should be leveraged so that multiple functions can be exported individually?. multi. default. all. named.

Which statement parses JSON successfully?. JSON.parse('"foo"');. JSON.parse('foo');. JSON.parse("foo");. JSON.parse('\'foo\'');.

A developer is creating a simple webpage with a button. The message gets displayed every time a user clicks the button, instead of just the first time. Which two code lines make this code work as required?. On line 04, use event.stopPropagation();. On line 02, use event.first to test if it is the first execution. On line 04, use button.removeEventListener('click', listen);. On line 06, add an option called {once: true} to button.addEventListener().

What is the value of result when Promise.race executes? (Assume car2 is fastest with 1500ms and resolves with "Car 2 completed"). Car 3 completed the race. Car 1 crashed in the race. Car 2 completed the race. Race is cancelled.

The developer has a function that prints "Hello" to an input name. What can the developer do to change the code to print "Hello World"? (sayHello takes a string, world is a function returning 'World'). Change line 7 to ()();. Change line 5 to function world() {. Change line 2 to console.log('Hello', name());. Change line 9 to sayHello(world());.

Refer to the code below: const pi = 3.1415926; What is the data type of pi?. Float. Double. Number. Decimal.

A developer has a requirement to generate SKU numbers that are always 19 characters long, starting with 'sku', and padded with zeros. let productSKU = '8675309'; Which statement assigns the correct value?. productSKU = productSKU.padEnd(16, '0').padStart('sku');. productSKU = productSKU.padStart(16, '0').padStart(19, 'sku');. productSKU = productSKU.padEnd(16, '0').padStart(19, 'sku');. productSKU = productSKU.padStart(19, '0').padStart('sku');.

Which three actions can be done using the JavaScript browser console?. Display a report showing the performance of a page. View and change the DOM of the page. Run code that is not related to the page. View and change security cookies. View, change, and debug the JavaScript code of the page.

A developer wants to use a module called DatePrettyPrint. This module exports one default function called printDate(). How can a developer import and use the printDate() function?. import printDate from '/path/DatePrettyPrint.js'; DatePrettyPrint.printDate();. import DatePrettyPrint() from '/path/DatePrettyPrint.js'; printDate();. import printDate from '/path/DatePrettyPrint.js'; printDate();. import {printDate} from '/path/DatePrettyPrint.js'; printDate();.

What is the order of the console output? console.log('Start'); Promise.resolve('Success').then(...); console.log('End');. Success Start End. End Start Success. Start Success End. Start End Success.

A developer creates a new web server that uses Node.js. It imports a server library that uses events and callbacks for handling server functionality. Which code logs an error at boot time with an event?. server.on('error', (error) => { console.log('ERROR', error); });. try { server.start(); } catch(error) { console.log('ERROR', error); }. server.error('error', (error) => { console.log('ERROR', error); });. server.catch('error', (error) => { console.log('ERROR', error); });.

Which statement accurately describes the behavior of the async/await keywords?. The associated function can only be called via asynchronous methods. The associated class contains some asynchronous functions. The associated function is asynchronous, but acts like synchronous code. The associated function sometimes returns a promise.

Which statement accurately describes an aspect of promises?. Arguments for the callback function passed to .then() are optional. In a .then() function, returning results is not necessary since callbacks will catch the result. .then() cannot be added after a catch. .then() manipulates and returns the original promise.

Which value can a developer expect when referencing country.capital.cityString? (Where city is Number("London")). undefined. 'London'. An error. NaN.

What are the values of objBook and newObjBook respectively after Object.preventExtensions(objBook) and newObjBook.author = 'Robert'?. {author: "Robert"} {author: "Robert", title: "JavaScript"}. {author: "Robert", title: "JavaScript"} undefined. {author: "Robert", title: "JavaScript"} {author: "Robert", title: "JavaScript"}. {title: "JavaScript"} {title: "JavaScript"}.

The developer needs to insert a code statement that does not require an import, logs an error when the Boolean statement evaluates to false, and works in both the browser and Node.js. console.debug(number % 2 === 0);. console.assert(number % 2 === 0);. console.error(number % 2 === 0);. assert(number % 2 === 0);.

Given the following code: let x = ('15' + 10) * 2; What is the value of x?. 1520. 50. 35. 3020.

Given the requirement to refactor the code above to JavaScript class format, which class definition is correct?. class Vehicle { constructor(name, price) { this.name = name; this.price = price; } priceInfo() { return `Cost of the ${this.name} is ${this.price}`; } }. class Vehicle { vehicle(name, price) { this.name = name; this.price = price; } priceInfo() { return `Cost of the ${this.name} is ${this.price}`; } }. class Vehicle { constructor() { this.name = name; this.price = price; } priceInfo() { return `Cost of the ${this.name} is ${this.price}`; } }. class Vehicle { constructor(name, price) { this.name = name; this.price = price; } function priceInfo() { return `Cost...`; } }.

Which option is true about the strict mode in imported modules?. Add the statement use strict = false; before any other statements in the module to enable not-strict mode. Imported modules are in strict mode whether you declare them as such or not. A developer can only reference notStrict() functions from the imported module. Add the statement use non-strict; before any other statements in the module to enable not-strict mode.

A developer wants to set up a secure web server with Node.js. Without using any third-party libraries, what should the developer add to index.js to create the secure web server?. const http = require('http');. const tls = require('tls');. const server = require('secure-server');. const https = require('https');.

Given the code below: const copy = JSON.stringify([new String('false'), new Boolean(false), undefined]); What is the value of copy?. '[false, {}]'. '["false", false, undefined]'. '["false", false, null]'. '["false", {}]'.

What are two unique features of functions defined with a fat arrow as compared to normal function definition?. The function receives an argument that is always in scope, called parentThis. The function uses the this from the enclosing scope. If the function has a single expression in the function body, the expression will be evaluated and implicitly returned. The function generates its own this making it useful for separating the function's scope.

What should a developer insert at line 15 to output the following message using the load method? > SNEGeneziz is loading a cartridge game: Super Monic 3x Force... Console16bit.prototype.load(gamename) = function() {. Console16bit.prototype.load = function() {. Console16bit.prototype.load(gamename) {. Console16bit.prototype.load = function(gamename) {.

Which command can the developer use to open the CLI debugger in their current terminal window?. node -i server.js. node start inspect server.js. node inspect server.js. node server.js --inspect.

What value can a developer expect when referencing o.js.secondCity? (Where city2 = String('New York') and returns secondCity: city2.toLowerCase()). undefined. 'New York'. An error (TypeError because o.js is accessed but getter executes without returning an object with .secondCity natively in some contexts, wait, getter returns the object, but here the property is evaluated dynamically... wait, the getter returns the object directly, so o.js.secondCity evaluates to 'new york' if properly defined. Actually, if there is a syntax error in the prompt's snippet, it's an error. The official answer is "An error" due to the function syntax). 'new york'.

Refer to the HTML below: <p> The current status of an Order: <span id="status"> In Progress </span> </p> Which JavaScript statement changes the text 'In Progress' to 'Completed'?. document.getElementById("status").innerHTML = 'Completed';. document.getElementById(".status").innerHTML = 'Completed';. document.getElementById("status").Value = 'Completed';. document.querySelector("#status").value = 'Completed';.

What is the value of result after the code executes? function changeValue(obj) { obj.value = obj.value / 2; } const objA = {value: 10}; const objB = objA; changeValue(objB);. 10. 5. NaN. undefined.

Which code should replace the placeholder comment on line 05 to hide accounts that do not match the search string? account.style.display = accountName.includes(parsedSearchString) ? /* Insert code here */ : '';. 'none' : 'block'. 'block' : 'none'. 'visible' : 'hidden'. 'hidden' : 'visible'.

What is the value of array after the code executes? array.splice(i, 1); i--; on array [1, 2, 3, 4, 4, 5, 4, 4] where array[i] == 4. [1, 2, 3, 4, 5, 4, 4]. [1, 2, 3, 4, 4, 5, 4]. [1, 2, 3, 4, 5, 4]. [1, 2, 3, 5].

Denunciar Test