js
What is a .js file?
text/javascript
JavaScript (.js) is a plain-text source file for the JavaScript language — the scripting language of the web, also used server-side via Node.js. It is dynamically typed and event-driven, with first-class functions, prototypes, and (in modern syntax) modules, classes, and async/await.
How to use a .js file
Use an example .js file to test syntax highlighters, linters (ESLint), formatters (Prettier), bundlers, and JavaScript parsers, or as editor and diff-viewer fixtures.
Download example .js files
- JavaScript — Hello WorldThe classic hello-world in modern JavaScript — a minimal function calling console.log, for testing highlighters, Node, and JS parsers.
- JavaScript — To-do list (class, private fields, async)A realistic JavaScript snippet with an ES class, private #fields, arrow functions, template literals, a getter, and async/await — for testing highlighters, ESLint, Prettier, and bundlers.
- Service Worker (sw.js)A sample cache-first service worker handling install, activate, and fetch events with an offline fallback — for testing service-worker registration, JS parsers, and PWA tooling.