Code Reference

Getting Started with JavaScript

JavaScript · Reference cheat sheet

Getting Started with JavaScript

JavaScript · Reference cheat sheet


📋 Overview

JavaScript (JS) is the language of the web browser and a popular choice on servers via Node.js. You write .js (or .mjs) files, or run snippets in browser DevTools / Node’s REPL.

🔧 Core concepts

IdeaMeaning
ECMAScript (ES)The language standard JS implements
Browser runtimeJS + DOM + Web APIs
Node.jsJS outside the browser (files, servers, CLIs)
EngineV8, SpiderMonkey, etc. execute your code
ModuleReusable file using import / export

Ways to try JS: browser console (F12), Node (node), or a simple HTML file with a <script> tag.

💡 Examples

Check Node version:

node --version

REPL one-liner:

node
> console.log("Hello")
Hello
> 2 + 2
4

Script file (hello.js):

console.log("Hello from Node");
node hello.js

In the browser (inline):

<!DOCTYPE html>
<html>
  <body>
    <script>
      console.log("Hello from the browser");
    </script>
  </body>
</html>

⚠️ Pitfalls

  • Browser JS and Node share the language but not all APIs (document vs fs).
  • Old tutorials use var everywhere — prefer let / const.
  • Forgetting to open the console makes console.log look like “nothing happened.”
  • File protocol + modules can be awkward; use a tiny local server when learning modules.

On this page