CRT-600 practice question 2 of 30
A developer has the function, shown below, 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?
Full set: 223 questionsThe console.log() function is a client-side JavaScript method used for debugging. It writes a message to the web console, which is a standard feature within the developer tools of modern web browsers. When the onload function executes in the browser, the string "Page has loaded!" is sent specifically to this console interface, not to the server, the performance profiler, or the visible webpage content. This tool is fundamental for developers to inspect code execution and variable states.
A. Terminal running the web server. This displays server-side logs. The provided JavaScript code runs on the client's browser, completely separate from the server's terminal environment.
B. Browser performance tools. These tools are for analyzing runtime performance, memory usage, and rendering speed. They do not display messages from console.log().
D. On the webpage. Displaying content directly on the webpage requires manipulating the Document Object Model (DOM), for example, using document.write() or setting an element's innerHTML. ---
1. MDN Web Docs (Mozilla): The console.log() method outputs a message to the web console. The web console is a tool available in web browsers for logging information
debugging
and interacting with the page's JavaScript context.
Source: MDN Web Docs
"Console: log() method"
Section: "Syntax".
Link: https://developer.mozilla.org/en-US/docs/Web/API/console/log
2. Salesforce Lightning Web Components Developer Guide: The official documentation for developing on the Salesforce platform explicitly instructs developers to use browser developer tools to debug JavaScript. It states
"To check the value of a component property in your browser’s developer tools
use console.log(). Open the browser console to see the output."
Source: Salesforce Lightning Web Components Developer Guide
"Debug Lightning Web Components"
Section: "Debug Your Code".
Link: https://developer.salesforce.com/docs/platform/lwc/guide/debug.html
3. W3C Recommendation: The Console API specification
which standardizes this functionality
defines the log method as a function that "outputs the arguments to the console."
Source: W3C
"Console API"
Section 4.1: "The log function".
Keep practicing
Take the free CRT-600 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other CRT-600 practice questions
- Question 3A developer needs to test this function: 01 const sum3 = (arr) => ( 02 if (!arr.length) r…
- Question 4Refer to the code below: Const resolveAfterMilliseconds = (ms) => Promise.resolve ( setTi…
- Question 10Refer to the following code block: class Animal{ constructor(name){ this.name = name; } m…
- Question 11A developer needs to debug a Node.js web server because a runtime error keeps occurring a…
- Question 12Refer to the string below: const str = 'Salesforce'; Which two statements result in the w…
- Question 14Given the code below: Which three code segments result in a correct conversion from numbe…
