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
| Idea | Meaning |
|---|---|
| ECMAScript (ES) | The language standard JS implements |
| Browser runtime | JS + DOM + Web APIs |
| Node.js | JS outside the browser (files, servers, CLIs) |
| Engine | V8, SpiderMonkey, etc. execute your code |
| Module | Reusable 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 --versionREPL one-liner:
node> console.log("Hello")
Hello
> 2 + 2
4Script file (hello.js):
console.log("Hello from Node");node hello.jsIn 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 (
documentvsfs). - Old tutorials use
vareverywhere — preferlet/const. - Forgetting to open the console makes
console.loglook like “nothing happened.” - File protocol + modules can be awkward; use a tiny local server when learning modules.