

The console also recognizes $() as an alias for document.querySelector() to select an element. Once we run the following code, the change will immediately be reflected on the page opened in the browser:

#RUNJS ONLINE CODE#
We can also write JS code to modify the page’s DOM, such as adding a heading element inside the body, as seen below. The expression will be evaluated, and the return value is printed to the console on the next line following the element of the page by checking in the console: Remember that the console is a REPL, so we can run JS code, such as arithmetic expressions, by typing it after the > prompt and hitting Enter/ Return. If you do, feel free to run clear() first to clear the console. We’ll be using Google Chrome for the following examples - also, feel free to try to follow along with the examples! When you pull up the console, you might see some messages that have been logged by the browser, depending on what site you’re on.
#RUNJS ONLINE HOW TO#
In this article, we’ll walk through how to open the developer console and run JS code right in your browser! Opening the browser console The console itself is also the place to view the messages that were logged by JS code, as well as any other information that the browser had documented, including network requests and security errors. The console is essentially a REPL ( Read-Evaluate-Print-Loop) that allows us to execute JS within the context of the page, such as modifying the page’s DOM ( Document Object Model) or logging to the console. JS code is normally added using the HTML element for executing in web browsers, but most modern browsers also provide a console as part of their developer tools where we can directly write and run JS, typically for testing and debugging purposes. Along with HTML and CSS, JavaScript (JS) makes up one of the core languages in web development.
