if you don't want to explicitly create a js file but still want to test your javascript code, you can use snippets to run your JS code.

Follow the steps here:

  1. Open Dev Tools
  2. Go to Sources Tab
  3. Under Sources tab go to snippets, + New snippet
  4. Paste your JS code in the editor then run Command + Enter on a Mac, or Ctrl + Enter on Windows or Linux. You should see the output in console if you are using console.log or similar to test. You can edit the current web page that you have open or run scripts, load more javascript files. (Just note: this snippets are not stored on as a js file, unless you explicitly did, on your computer so if you remove chrome you will lose all your snippets);
  5. You also have a option to save as your snippet if you right click on your snippet.

Answer from ะ ะะ’ะ˜ on Stack Overflow
๐ŸŒ
BrowserStack
browserstack.com โ€บ home โ€บ guide โ€บ how to test javascript in browsers (with 5 methods)
How to test JavaScript in Browsers (with 5 Methods) | BrowserStack
March 28, 2025 - The infrastructure enables a developer ... like Chrome, Safari, IE, Edge, Firefox, etc. Users can also access free tools like responsive layout testing and screenshot testing, which tests the validity of JavaScript on a particular web page. The wide range of OS-browser combinations and the latest real devices provided by BrowserStack for testing purposes is unmatched. Itโ€™s pretty simple to use and instantly test Javascript in your browser. ... JSFiddle is an online tool that ...
๐ŸŒ
LambdaTest
lambdatest.com โ€บ software-testing-questions โ€บ how-to-run-javascript-in-chrome-browser
How to Run JavaScript in Chrome Browser: A Quick Guide
Alternatively, click the three-dot menu in the top-right corner of Chrome, select "More tools," and then select the Developer tools option. When DevTools opens, go to the Console tab.
๐ŸŒ
BrowserStack
browserstack.com โ€บ home โ€บ guide โ€บ how to run javascript in chrome browser
How to Run JavaScript in Chrome Browser | BrowserStack
April 4, 2025 - Performance Optimization: Chromeโ€™s V8 JavaScript engine ensures faster script execution, optimizing web applications for better speed, responsiveness, and efficiency. Real-Time Testing: Chromeโ€™s Developer Console allows developers to instantly execute and modify JavaScript code, making it easy to test scripts and see results without reloading the page.
๐ŸŒ
Code Beautify
codebeautify.org โ€บ javascript-tester
Javascript Tester to test Javascript code online with Console
It helps to debug your Javascript. Tester JS Online works well on Windows, MAC, Linux, Chrome, Firefox, Edge, and Safari.
๐ŸŒ
BrowserStack
browserstack.com โ€บ home โ€บ guide โ€บ how to run javascript code in a browser?
How to Run JavaScript Code in a Browser? | BrowserStack
November 26, 2024 - Open Chrome โ†’ Press Ctrl + Shift + I (Windows) / Cmd + Option + I (Mac). Select Console. ... Press Enter. ... Open console with Option + Cmd + C. ... Press Enter. This guide explains how to run JavaScript code in different browsers and test ...
๐ŸŒ
Chrome Developers
developer.chrome.com โ€บ docs โ€บ chrome devtools โ€บ run javascript in the console
Run JavaScript in the Console | Chrome DevTools | Chrome for Developers
April 18, 2018 - DevTools lets you pause a script in the middle of its execution. While you're paused, you can use the Console to view and change the page's window or DOM at that moment in time. This makes for a powerful debugging workflow. See Get Started With Debugging JavaScript for an interactive tutorial.
๐ŸŒ
LambdaTest
lambdatest.com โ€บ home โ€บ blog โ€บ best 13 tools to test javascript code
Best 13 Tools To Test JavaScript Code | LambdaTest
October 31, 2023 - Execute the tests using the chosen frameworkโ€™s command-line interface or test runner. Analyze the results to ensure your code functions as intended. To test JS code online, you can use various platforms like CodePen, JSFiddle, or Replit.
Find elsewhere
๐ŸŒ
TestDome
testdome.com โ€บ tests โ€บ javascript-online-test โ€บ 14
JavaScript Online Test | TestDome
The JavaScript online test assesses knowledge of programming in the JavaScript language and core front-end web development concepts. This test contains a series of live coding tasks that are executed inside the Google Chrome web browser.
๐ŸŒ
Web Toolkit Online
webtoolkitonline.com โ€บ javascript-tester.html
JavaScript Tester online
Run and test your JavaScript code securely with our 100% local online tool. No data is sent over the Internet โ€“ everything runs in your browser! Fast, simple, and secure.
๐ŸŒ
OneCompiler
onecompiler.com โ€บ javascript
JavaScript Online Compiler & Interpreter
Executable in both browser and server which has Javascript engines like V8(chrome), SpiderMonkey(Firefox) etc.
๐ŸŒ
Chrome Web Store
chromewebstore.google.com โ€บ detail โ€บ run-javascript โ€บ lmilalhkkdhfieeienjbiicclobibjao
Run Javascript - Chrome Web Store
๐ŸŽฏ Instant Website Customization โœ… Run custom JavaScript on ANY website automatically โœ… Real-time code editor with syntax highlighting โœ… Domain-specific scripts that persist forever โœ… One-click enable/disable toggle ๐Ÿ’ป Professional Developer Experience โœ… Built-in Ace Editor with intelligent code completion โœ… Multiple jQuery versions (1.12.4, 2.2.4, 3.3.1) or go library-free โœ… Persistent storage across browser sessions โœ… Advanced error handling and debugging tools ๐Ÿ”’ Enterprise-Grade Security โœ… Manifest V3 compliant (latest Chrome standards) โœ… Sandboxed execution envir
๐ŸŒ
JSFiddle
jsfiddle.net
JSFiddle - Code Playground
JSFiddle - Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle.
๐ŸŒ
Quora
quora.com โ€บ How-do-you-test-JavaScript-code-in-a-browser
How to test JavaScript code in a browser - Quora
Now open your page that has your JS, click left mouse button and click on 'Inspect Element'. An Window consisting of tabs like 'Elements', 'Network', 'Sources' ... etc will open in current window.
๐ŸŒ
DZone
dzone.com โ€บ coding โ€บ javascript โ€บ how to test javascript code in a browser
How to Test JavaScript Code in a Browser
May 11, 2022 - Thus Google Chrome must be installed on your local machine for this method of JavaScript to work. It launches Google Chrome in headless mode for its operation. CodePen is one of the best online tools to test your HTML, CSS and JavaScript code online.
๐ŸŒ
WhatIsMyBrowser.com
whatismybrowser.com โ€บ detect โ€บ is-javascript-enabled
Is JavaScript enabled? - WhatIsMyBrowser.com
June 26, 2024 - Nearly all websites need Javascript enabled these days, are you sure if you've got it enabled? This website will tell you if you have JavaScript enabled.