JavaScript Developer - Set 3
|
|
Título del Test:
![]() JavaScript Developer - Set 3 Descripción: Set 3 JavaScript Developer |



| Comentarios |
|---|
NO HAY REGISTROS |
|
What is the value of output 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]. A developer has an isDog function that takes one argument, pet. They want to schedule the function to run every minute. What is the correct syntax for scheduling this function?. setInterval(isDog('cat'), 60000);. setTimeout(isDog, 60000, 'cat');. setTimeout(isDog('cat'), 60000);. setInterval(isDog, 60000, 'cat');. A developer wants to use a try...catch statement to catch any error that countSheep() may throw and pass it to a handleError() function. What is the correct implementation?. try { setTimeout(function() { countSheep(); }, 1000); } catch(e) { handleError(e); }. setTimeout(function() { try { countSheep(); } catch(e) { handleError(e); } }, 1000);. try { countSheep(); } finally { handleError(e); }. try { countSheep(); } handleError(e) { catch(e); }. Which two functions can replace line 01 and return 58 to sum? const addBy = ?; const addByEight = addBy(8); const sum = addByEight(50);. const addBy = function(num1) { return function(num2) { return num1 + num2; } }. const addBy = (num1) => num1 + num2;. const addBy = function(num1) { return num1 * num2; }. const addBy = (num1) => (num2) => num1 + num2;. Where can the developer see the log statement after loading the page in the browser? console.log("Page has loaded!");. On the browser JavaScript console. On the terminal console running the web server. On the webpage console log. In the browser performance tools log. Which two assert statements are valid tests for this function? sum3 function that sums the first three elements. console.assert(sum3(['hello', 2, 3, 4]) === NaN);. console.assert(sum3([-3, 2]) === -1);. console.assert(sum3([1, '2']) == 12);. console.assert(sum3([]) === 0);. Which two statements could be inserted at line 17 to enable the function call on line 18? leo.roar();. Object.assign(leo, Tiger);. leo.roar = () => { console.log('They\'re pretty good!'); };. leo.prototype.roar = () => { console.log('They\'re pretty good!'); };. Object.assign(leo, tony);. Which two statements result in the array [1, 2, 3, 4, 5] from let inArray = [[1,2], [3,4,5]];?. [].concat([inArray]);. [].concat.apply(inArray, []);. [].concat.apply([], inArray);. [].concat(...inArray);. What is the result when the Promise in the execute function is rejected? promise.catch(() => console.log('Rejected')).then(() => console.log('Resolved4'));. Resolved1 Resolved2 Resolved3 Resolved4. Resolved1 Resolved2 Resolved3 Rejected Resolved4. Rejected Resolved4. Rejected. What is the output when executing the code above? (SaleItem extending Item, overriding prototype.description). This is a Scarf / Uncaught TypeError / This is a Shirt / This is a discounted Shirt. This is a Scarf / This is a Shirt / This is a Scarf / This is a discounted Shirt. This is a Scarf / This is a Shirt / This is a discounted Scarf / This is a discounted Shirt. This is a Scarf / Uncaught TypeError / This is a Scarf / This is a discounted Shirt. A developer removes the HTML class attribute from the checkout button, so now it is simply <button>Checkout</button>. There is a test to verify the existence of the checkout button, however it looks for a button with class="blue". The test fails because no such button is found. Which type of test category describes this test?. False positive. True positive. False negative. True negative. Based on the code, what must be true about the printPrice function of the PricePrettyPrint module for this import to work? import printPrice from '/path/PricePrettyPrint.js';. printPrice must be a named export. printPrice must be an all export. printPrice must be the default export. printPrice must be a multi export. Considering that JavaScript is single-threaded, what is the output of line 08 after the code executes? total = 10; setInterval(()=>{total++; clearInterval(interval); total++;}, 0); total++; console.log(total);. 10. 13. 12. 11. Given a value, which three options can a developer use to detect if the value is NaN?. Number.isNaN(value). value == NaN. Object.is(value, NaN). value === Number.NaN. value !== value. After user acceptance testing, the developer is asked to change the webpage background based on user's location. The tester reports that the background is not changing, however it works as required when viewing on the developer's computer. Which two actions will help determine accurate results?. The tester should clear their browser cache. The developer should rework the code. The developer should inspect their browser refresh settings. The tester should disable their browser cache. Which statement should be inserted in the placeholder on line 02 to allow for a variable to be set to a new instance of a story with the three attributes correctly populated?. constructor() {. super(body, author, viewCount) {. constructor(body, author, viewCount) {. function Story(body, author, viewCount) {. Refer to the string below: const str = 'Salesforce'; Which two statements result in the word 'Sales'?. str.substr(1, 5);. str.substring(1, 5);. str.slice(0, 5);. str.substring(0, 5);. Given the following code: let x = null; console.log(typeof x); What is the output of line 02?. "null". "undefined". "x". "object". To ensure that visitors have a good experience, a script named personalizeWebsiteContent needs to be executed when the webpage is fully loaded (HTML content and all related files), in order to do some custom initializations. Which implementation should be used?. Add a listener to the window object to handle the DOMContentLoaded event. Add a handler to the personalizeWebsiteContent script to handle the DOMContentLoaded event. Add a listener to the window object to handle the load event. Add a handler to the personalizeWebsiteContent script to handle the load event. A developer uses a client that makes a GET request that uses a Promise to handle the request. getRequest returns a Promise. Which code modification can the developer make to gracefully handle an error?. Wrap in try...catch without async. requestPromise().then((response) => { handleResponse(response); }).catch((error) => { handleError(error); });. requestPromise().then(...).finally(...). try { requestPromise().then(...) } catch(e) {}. Given the requirement to refactor the code above to JavaScript class format, which class definition is correct?. class Vehicle { vehicle(name, price) { ... } }. class Vehicle { constructor(name, price) { this.name = name; this.price = price; } priceInfo() { return `Cost...`; } }. class Vehicle { constructor() { ... } }. class Vehicle { constructor(name, price) { ... } function priceInfo() { ... } }. Which two statements correctly execute the runParallel() function?. runParallel().then(function(data) { return data; });. runParallel().done(function(data) { return data; });. async runParallel().then(data);. runParallel().then(data => console.log(data));. In lines 04 and 08, 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);. Which code executes sayHello once, two minutes from now?. setTimeout(sayHello(), 120000);. delay(sayHello, 120000);. setInterval(sayHello, 120000);. setTimeout(sayHello, 120000);. A developer tries to retrieve all cookies, then sets a certain key value pair in the cookie: document.cookie; document.cookie = 'key=John Smith'; What is the behavior?. Cookies are not read because line 01 should be document.cookies, but the key value is set and all cookies are wiped. Cookies are read and the key value is set, the remaining cookies are unaffected. Cookies are read, but the key value is not set because the value is not URL encoded. Cookies are read and the key value is set, and all cookies are wiped. A developer is leading the creation of a new browser application that will serve a single page application. The team wants to use a new web framework Minimalist.js. The lead developer wants to advocate for a more seasoned web framework/library that already has a community around it. Which two frameworks/libraries should the lead developer advocate for?. React. Koa. Vue. Express. When the user clicks the button, the output is always "Hello". What needs to be done to make this code work as expected?. Replace line 02 with button.addCallback("click", function() {. Replace line 03 with const input = document.getElementByName('input');. Replace line 04 with console.log(input.value);. Replace line 02 with button.addEventListener("onclick", function() {. A team at Universal Containers works on a big project and use yarn to deal with the project's dependencies. A developer added a dependency to manipulate dates and pushed the updates to the remote repository. The rest of the team complains that the dependency does not get downloaded when they execute yarn. What could be the reason for this?. The developer missed the option --add when adding the dependency. The developer added the dependency as a dev dependency, and YARN_ENV is set to production. The developer added the dependency as a dev dependency, and NODE_ENV is set to production. The developer missed the option --save when adding the dependency. What is displayed when myFunction(true) is called? (let x = 1; var y = 1; if(true){ let x = 2; var y = 2; ... }). 2 2 1 1. 2 2 undefined undefined. 2 2 2 2. 2 2 1 2. All the elements include the same ad-library-item class. They are hidden by default, and they are randomly displayed while the user navigates through the page. Tired of all the ads, what can the developer do to temporarily and quickly remove them?. Use the DOM inspector to prevent the load event to be fired. Use the browser console to execute a script that prevents the load event to be fired. 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. 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(gamename) {. Console16bit = Object.create(GameConsole.prototype).load = function(gamename) {. Console16bit.prototype.load = function(gamename) {. What are two unique features of functions defined with a fat arrow as compared to normal function definition?. If the function has a single expression in the function body, the expression will be evaluated and implicitly returned. The function uses the this from the enclosing scope. The function receives an argument that is always in scope, called parentThis, which is the enclosing lexical scope. The function generates its own this making it useful for separating the function's scope from its enclosing scope. A developer has two ways to write a function: Option A: `this.growl = () => {}` inside constructor. Option B: `Monster.prototype.growl = () => {}`. After creating 1000 monster objects, how many growl methods are created with Option A and Option B?. 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 two statements result in the array [1, 2, 3, 4, 5] from let inArray = [[1,2], [3,4,5]];?. [].concat([inArray]);. [].concat.apply([], inArray);. [].concat(...inArray);. [].concat([...inArray]);. What happens due to the lack of the new keyword on line 02? `const m = Monster();` (where Monster sets `this.name = 'hello'`). window.m is assigned the correct object. The m variable is assigned the correct object but this.name remains undefined. The m variable is assigned the correct object. window.name is assigned to 'hello' and the variable m remains undefined. A developer needs to debug a Node.js web server because a runtime error keeps occurring at one of the endpoints. The developer wants to debug the Node.js server only using the terminal. Which command can the developer use to open the CLI debugger in their current terminal window?. node start inspect server.js. node -i server.js. node inspect server.js. node server.js --inspect. 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", {}]'. Refer to the following code: let codeName = 'Bond'; let sampleText = `The name is ${codeName}, Jim ${codeName}`; A developer is trying to determine if a certain substring is part of a string. Which three code statements return true?. sampleText.includes('Jim');. sampleText.includes('The', 1);. sampleText.includes('${codeName}');. sampleText.indexOf('Bond') !== -1;. sampleText.includes('${codeName}', 1);. What is the value of result when Promise.race executes? let car1 = new Promise((_, reject) => setTimeout(reject, 2000, "Car 1 crashed")); let car2 = new Promise(resolve => setTimeout(resolve, 1500, "Car 2 completed")); let car3 = new Promise(resolve => setTimeout(resolve, 3000, "Car 3 completed")); Promise.race([car1, car2, car3]).then(value => { let result = `${value} the race.`; });. Car 3 completed the race. Car 2 completed the race. Race is cancelled. Car 1 crashed in the race. Given the following code: counter = 0; const logCounter = () => { console.log(counter); }; logCounter(); setTimeout(logCounter, 2100); setInterval(() => { counter++; logCounter(); }, 1000); What will be the first four numbers logged?. 0 1 2 2. 0 1 2 3. 0 1 1 2. 0 0 1 2. Which three actions can be done using the JavaScript browser console?. View and change the DOM of the page. View, change, and debug the JavaScript code of the page. Run code that is not related to the page. Display a report showing the performance of a page. View and change security cookies. A developer has a fizzbuzz function that returns 'fizz' for div by 3, 'buzz' for div by 5, 'fizzbuzz' for div by both 3 and 5, and empty string otherwise. Which two test cases properly test scenarios for the fizzbuzz function?. let res = fizzbuzz(true); console.assert(res === '');. let res = fizzbuzz(3); console.assert(res === '');. let res = fizzbuzz(5); console.assert(res === 'fizz');. let res = fizzbuzz(15); console.assert(res === 'fizzbuzz');. Refer to the following code: let obj = { foo: 1, bar: 2 }; let output = []; for (let something of obj) { output.push(something); } console.log(output); What is the value of output?. An error will occur due to the incorrect usage of the for...of statement. [1, 2]. ["foo", "bar"]. ["foo:1", "bar:2"]. Which two code snippets show working examples of a recursive function?. const sumToTen = numVar => { if (numVar < 0) return; return sumToTen(numVar + 1); };. function factorial(numVar) { if (numVar < 0) return; if (numVar === 0) return 1; return numVar - 1; }. const factorial = numVar => { if (numVar < 0) return; if (numVar === 0) return 1; return numVar * factorial(numVar - 1); };. let countingDown = function(startNumber) { if (startNumber > 0) { console.log(startNumber); return countingDown(startNumber - 1); } else { return startNumber; } };. Given two expressions var1 and var2, what are two valid ways to return the concatenation of the two expressions and ensure it is data type string?. String(var1).concat(var2). String.concat(var1 + var2). var1 + var2. var1.toString() + var2.toString(). Refer to the code below: const myFunction = arr => { return arr.reduce((result, current) => { return result + current; }, 10); } What is the output of this function when called with an empty array?. Returns 0. Throws an error. Returns NaN. Returns 10. Given the code below: let usersList = [john, jane, emily]; Which method can be used to provide a visual representation of the list of users and to allow sorting by the name or email attribute?. console.table(usersList);. console.group(usersList);. console.groupCollapsed(usersList);. console.info(usersList);. What is logged to the console? setTimeout(() => { console.log(1); }, 0); console.log(2); new Promise((resolve, reject) => { setTimeout(() => { reject(console.log(3)); }, 1000); }).catch(() => { console.log(4); }); console.log(5);. 2 5 1 3 4. 1 2 4 3 5. 1 2 5 3 4. 2 1 4 3 5. Refer to the code below: let timerId = setInterval(timedFunction, 1000); Which statement allows a developer to cancel the scheduled timed function?. clearInterval(timerId);. removeInterval(timerId);. removeInterval(timedFunction);. clearInterval(timedFunction);. To ensure that visitors have a good experience, a script named personalizeWebsiteContent needs to be executed to do some custom initialization when the webpage is fully loaded with HTML content and all related files. Which statement should be used?. document.addEventListener('DOMContentLoaded', personalizeWebsiteContent);. document.addEventListener('onDOMContentLoaded', personalizeWebsiteContent);. window.addEventListener('load', personalizeWebsiteContent);. window.addEventListener('onload', personalizeWebsiteContent);. 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. Which statement meets these requirements?. console.assert(number % 2 === 0);. assert(number % 2 === 0);. console.error(number % 2 === 0);. console.debug(number % 2 === 0);. Refer to the following code: class Ship { constructor(size) { this.size = size; } } class FishingBoat extends Ship { constructor(size, capacity) { /* Missing code */ this.capacity = capacity; } } Which statement should be added for the code to work?. super(size);. ship.size = size;. super.size = size;. this.size = size;. A developer initiates a server with the file server.js and adds dependencies in the source code's package.json that are required to run the server. Which command should the developer run to start the server locally?. node start. npm start. npm start server.js. start server.js. A developer has a function that is called when a page loads: function onLoad() { console.log("Page has loaded!"); } Where can the developer see the log statement after loading the page in the browser?. On the browser JavaScript console. On the terminal console running the web server. On the webpage console log. In the browser performance tools log. Given the code below: let numValue = 1982; Which three code segments result in a correct conversion from number to string?. let strValue = numValue.toText();. let strValue = String(numValue);. let strValue = "" + numValue;. let strValue = numValue.toString();. let strValue = (String)numValue;. Which two console logs output NaN?. console.log(10 / 0);. console.log(parseInt('two'));. console.log(10 / Number('5'));. console.log(10 / 'five');. A developer uses a parsed JSON string to work with user information. Which two options access the email attribute in the object?. userInformation.email. userInformation.get("email"). userInformation["email"]. userInformation[email]. What is the result when the Promise in the execute function is rejected? promise.then(()=>console.log('R1')).then(()=>console.log('R2')).catch(()=>console.log('Rejected')).then(()=>console.log('R4'));. Resolved1 Resolved2 Rejected Resolved4. Resolved1 Resolved2 Resolved3 Rejected Resolved4. Rejected. Rejected Resolved4. Which three browser specific APIs are available for developers to persist data between page loads?. localStorage. indexedDB. cookies. global variables. IIFEs. Given a value, which two options can a developer use to detect if the value is NaN?. value === Number.NaN. value == NaN. isNaN(value). Object.is(value, NaN). 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 DatePrettyPrint() from '/path/DatePrettyPrint.js'; printDate();. import DatePrettyPrint from '/path/DatePrettyPrint.js'; DatePrettyPrint.printDate();. import printDate from '/path/DatePrettyPrint.js'; printDate();. import {printDate} from '/path/DatePrettyPrint.js'; printDate();. Which option is true about the strict mode in imported modules?. Imported modules are in strict mode whether you declare them as such or not. Add the statement use strict = false; before any other statements in the module to enable not-strict mode. A developer can only reference notStrict() functions from the imported module. Add the statement use non-strict; before any other statements in the module. When does Promise.finally get called?. When rejected. When resolved and settled. When resolved. When resolved or rejected. Which statement accurately describes the behavior of the async/await keywords?. The associated class contains some asynchronous functions. The associated function can only be called via asynchronous methods. The associated function sometimes returns a promise. The associated function is asynchronous, but acts like synchronous code. Refer to the HTML below: <div id="main"><ul><li>Leo</li><li>Tony</li></ul></div> Which JavaScript statement results in changing "Leo" to "The Lion"?. document.querySelectorAll('#main #Leo').innerHTML = 'The Lion';. document.querySelector('#main li:second-child').innerHTML = 'The Lion';. document.querySelectorAll('#main li.Leo').innerHTML = 'The Lion';. document.querySelector('#main li:nth-child(1)').innerHTML = 'The Lion';. |




