What Is JavaScript? Features, History, Engines and Uses
JavaScript is the programming language of the web, and today it also runs servers, command-line tools and test automation frameworks such as Playwright and Cypress. In this first lesson you will learn what JavaScript is, where it runs, how it is standardised and why it is the best first language for anyone who wants to build or test web applications.
📖 What You’ll Learn: what JavaScript is, its key features, its history and versions (ECMAScript), engines and runtimes (V8, Node.js), what you can build with it, how it compares with Java, TypeScript and Python, and your first program.
🌐 What Is JavaScript?
Definition: JavaScript is a high-level, dynamically typed, multi-paradigm programming language. It was created to make web pages interactive, and it is the only programming language that every web browser runs natively.
Let us unpack the important words in that definition:
- High-level: you write readable code; memory is managed for you by a garbage collector.
- Dynamically typed: a variable can hold any type of value, and types are checked while the program runs, not before.
- Multi-paradigm: you can write procedural, object-oriented or functional code.
- Single-threaded with an event loop: one piece of your code runs at a time, but slow work such as network calls runs in the background without blocking.
- Just-in-time (JIT) compiled: modern engines compile JavaScript to machine code while it runs, which makes it fast.
Here is the smallest useful JavaScript program. console.log() prints a value to the console (the terminal in Node.js, or the DevTools console in a browser).
📄 hello.js
console.log("Hello, JavaScript!");
console.log("2 + 3 =", 2 + 3);
⌨️ Terminal
node hello.js
🖥️ Output
Hello, JavaScript!
2 + 3 = 5
You will install Node.js in the next lesson. Until then you can paste the code into your browser console: press F12 in Chrome or Edge and open the Console tab.
⭐ Key Features of JavaScript
These features explain why JavaScript is everywhere:
| Feature | What it means for you |
|---|---|
| Runs in every browser | No install is needed to run JavaScript on a web page. |
| Runs outside the browser | Node.js, Deno and Bun run JavaScript on servers and your computer. |
| Dynamic typing | Quick to write; types are checked at run time. |
| First-class functions | Functions are values: store them in variables and pass them to other functions. |
| Objects and prototypes | Objects can inherit from other objects; the class syntax builds on this. |
| Asynchronous by design | Promises and async/await handle network and file work without freezing. |
| Huge ecosystem | npm, the JavaScript package registry, hosts millions of free packages. |
The next example shows dynamic typing and first-class functions in action. typeof returns the type of a value as a string.
📄 features.js
let value = 42;
console.log(typeof value); // number
value = "forty-two"; // the same variable now holds a string
console.log(typeof value);
// A function stored in a variable and passed to another function
const double = (n) => n * 2;
console.log([1, 2, 3].map(double));
⌨️ Terminal
node features.js
🖥️ Output
number
string
[ 2, 4, 6 ]
valuefirst holds a number and then a string. JavaScript allows this because it is dynamically typed.doubleis an arrow function stored in a constant.map(double)passes the function to an array method, which calls it once for each item.
📜 A Short History: From Netscape to ECMAScript 2026
Brendan Eich created JavaScript at Netscape in 1995, in about ten days. It was first called Mocha, then LiveScript, and was renamed JavaScript for marketing reasons. Despite the name, it is not related to Java.
To stop browsers from creating incompatible versions, JavaScript was standardised by Ecma International as ECMAScript. The committee that evolves the language is called TC39. “JavaScript” is the language you write; “ECMAScript” is the specification that engines implement.
| Version | Year | Highlights |
|---|---|---|
| ES1 | 1997 | First standard |
| ES3 | 1999 | Regular expressions, try/catch |
| ES5 | 2009 | Strict mode, JSON, array methods such as forEach and map |
| ES2015 (ES6) | 2015 | let/const, arrow functions, classes, modules, promises, template literals |
| ES2017 | 2017 | async/await |
| ES2020 | 2020 | Optional chaining ?., nullish coalescing ??, BigInt |
| ES2022 to ES2025 | 2022–2025 | Array.prototype.at(), private class fields, Object.groupBy, new Set methods |
| ES2026 | 2026 | The current edition. A new edition is published every June. |
💡 Tip: Since 2015 a new ECMAScript edition comes out every year, so people name versions by year (ES2020, ES2026) instead of by number. When someone says “modern JavaScript”, they usually mean ES2015 and later.
⚙️ JavaScript Engines and Runtimes
Definition: a JavaScript engine is the program that reads and executes JavaScript code. A runtime is an engine plus extra features (APIs) for a particular environment.
| Engine | Used by |
|---|---|
| V8 | Google Chrome, Microsoft Edge, Node.js, Deno |
| SpiderMonkey | Mozilla Firefox |
| JavaScriptCore | Apple Safari, Bun |
The language is the same everywhere, but the extra APIs differ. A browser gives you document and window for the web page. Node.js gives you process, the file system (fs) and other server features instead. This program prints details about the Node.js runtime it runs on:
📄 runtime.js
console.log("Node.js version:", process.version);
console.log("V8 engine version:", process.versions.v8);
console.log("Running in a browser?", typeof window !== "undefined");
⌨️ Terminal
node runtime.js
🖥️ Output
Node.js version: v26.13.0
V8 engine version: 14.6.202.34-node.40
Running in a browser? false
processexists only in Node.js. In a browser this line would fail withReferenceError: process is not defined.typeof windowis"undefined"in Node.js because there is no browser window.
🧰 What Can You Build with JavaScript?
- Interactive websites: menus, forms, validation, live search, single-page apps with React, Angular or Vue.
- Back-end servers and APIs with Node.js and frameworks such as Express or Fastify.
- Test automation: Playwright, Cypress, WebdriverIO, Jest and Vitest all use JavaScript or TypeScript.
- Command-line tools and build tools (npm, Vite, ESLint are written in JavaScript).
- Desktop and mobile apps with Electron (VS Code is built with it) and React Native.
A small, realistic example: calculate a shopping-cart total, the kind of logic a tester often checks.
📄 cart.js
const cart = [
{ item: "Keyboard", price: 49.99, qty: 1 },
{ item: "Mouse", price: 19.5, qty: 2 },
];
let total = 0;
for (const line of cart) {
total += line.price * line.qty;
}
console.log(`Items: ${cart.length}`);
console.log(`Total: $${total.toFixed(2)}`);
⌨️ Terminal
node cart.js
🖥️ Output
Items: 2
Total: $88.99
cartis an array of objects, the most common data shape in JavaScript.for...ofloops over each line of the cart.toFixed(2)formats the number with two decimal places. The template literal (back-ticks) inserts values with${...}.
⚖️ JavaScript vs Java vs TypeScript vs Python
| JavaScript | TypeScript | Java | Python | |
|---|---|---|---|---|
| Typing | Dynamic | Static (checked before running) | Static | Dynamic |
| Runs in the browser | Yes, natively | After compiling to JavaScript | No | No |
| Main use | Web front end, Node.js back end, testing | Large JavaScript projects | Enterprise back ends, Android | Data, scripting, testing |
| Test tools | Playwright, Cypress, Jest | Playwright, Cypress | Selenium, TestNG | Pytest, Playwright, Selenium |
TypeScript is JavaScript plus type annotations. Every JavaScript program is valid TypeScript, so learning JavaScript first is the right order. When you are ready, the Playwright with TypeScript tutorial builds on this course.
🧪 JavaScript for Testers: Your First Check
Testing is comparing what a program does with what it should do. Node.js has a built-in assert module for that. This test checks a small discount function:
📄 discount.test.js
const assert = require("node:assert/strict");
function discount(price, percent) {
return price - (price * percent) / 100;
}
assert.equal(discount(200, 10), 180);
assert.equal(discount(99.99, 0), 99.99);
console.log("All checks passed");
⌨️ Terminal
node discount.test.js
🖥️ Output
All checks passed
When a check fails, Node.js stops and shows you the expected and actual values. Here the function has a bug: it adds the discount instead of subtracting it.
📄 discount-bug.test.js
const assert = require("node:assert/strict");
function discount(price, percent) {
return price + (price * percent) / 100; // bug
}
assert.equal(discount(200, 10), 180);
⌨️ Terminal
node discount-bug.test.js
🖥️ Output
node:internal/assert/utils:146
throw error;
^
AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
220 !== 180
at Object.<anonymous> (/home/you/js-course/discount-bug.test.js:7:8)
{
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: 220,
expected: 180,
operator: 'strictEqual',
diff: 'simple'
}
Node.js v26.13.0
⚠️ Watch out: Read error messages from the top. AssertionError tells you a check failed, 220 !== 180 shows actual versus expected, and the line number points to the failing check. Test frameworks such as Playwright and Jest print the same kind of message.
🚫 A Common Beginner Error: JavaScript Is Case-Sensitive
console, Console and CONSOLE are three different names. Only the lowercase one exists:
📄 case.js
Console.log("Hello");
⌨️ Terminal
node case.js
🖥️ Output
/home/you/js-course/case.js:1
Console.log("Hello");
^
ReferenceError: Console is not defined
at Object.<anonymous> (/home/you/js-course/case.js:1:1)
Node.js v26.13.0
Fix: write console.log in lowercase. A ReferenceError always means “I cannot find anything with this name”; check the spelling and the capital letters first.
📝 Practice Questions with Answers
Try each question on your own first, then open the answer to check your work. Run the code with node practice.js.
Q1. Write a program that prints Hello, JavaScript! on the first line and My name is Asha on the second line.
Show answer
📄 practice1.js
console.log("Hello, JavaScript!");
console.log("My name is Asha");🖥️ Output
Hello, JavaScript!
My name is AshaEach console.log() call prints one line.
Q2. Print the Node.js version and the V8 engine version on one line, separated by | .
Show answer
📄 practice2.js
console.log(process.version + " | V8 " + process.versions.v8);🖥️ Output
v26.13.0 | V8 14.6.202.34-node.40Your numbers may differ; any Node.js 22 or later works for this course.
Q3. Print the type of each value: 42, "42", true, undefined and null. Which result surprises you?
Show answer
📄 practice3.js
console.log(typeof 42);
console.log(typeof "42");
console.log(typeof true);
console.log(typeof undefined);
console.log(typeof null);🖥️ Output
number
string
boolean
undefined
objecttypeof null returns "object". This is a bug from the first version of JavaScript that was never fixed, because fixing it would break old websites. null is really its own primitive type.
Q4. This code throws an error. Find and fix the mistake.
console.Log("Ready");Show answer
The method name is log in lowercase. console.Log is undefined, so calling it throws TypeError: console.Log is not a function.
📄 practice4.js
console.log("Ready");🖥️ Output
ReadyQ5. Three items cost 12.5, 7.25 and 30. Print the total with two decimal places, like Total: 49.75.
Show answer
📄 practice5.js
const total = 12.5 + 7.25 + 30;
console.log("Total: " + total.toFixed(2));🖥️ Output
Total: 49.75Q6. Write a check with node:assert/strict that proves Math.max(3, 9, 4) returns 9, and print Max check passed if it does.
Show answer
📄 practice6.js
const assert = require("node:assert/strict");
assert.equal(Math.max(3, 9, 4), 9);
console.log("Max check passed");🖥️ Output
Max check passedIf the check failed, Node.js would throw an AssertionError and the last line would never run.
🧠 MCQ Quiz: What Is JavaScript?
10 questions on this lesson. Pick one answer for each, then press Check answers to see your score and an explanation for every question.
- Who created JavaScript, and in which year?Answer: Brendan Eich, 1995. Brendan Eich wrote the first version at Netscape in 1995. James Gosling created Java; Guido van Rossum created Python.
- What is ECMAScript?Answer: The standard specification that JavaScript engines implement. ECMAScript is the language specification maintained by Ecma TC39; JavaScript is the language that follows it.
- Which JavaScript engine does Node.js use?Answer: V8. Node.js is built on Google’s V8 engine, the same engine as Chrome.
- What does
typeof nullreturn?Answer:"object". It is a long-standing quirk from JavaScript’s first version;nullis still a primitive value. - Which statement about JavaScript and Java is true?Answer: They are different languages with similar names. The name “JavaScript” was chosen for marketing in 1995; the languages are unrelated.
- What does “dynamically typed” mean?Answer: A variable can hold values of different types, and types are checked while the program runs. In JavaScript
let x = 1; x = "one";is valid, because types belong to values, not variables. - Which object exists in Node.js but not in a web page?Answer:
process.processis a Node.js global.document,windowandlocalStorageare browser APIs. - What happens when you run
Console.log("Hi")?Answer:ReferenceError: Console is not defined. JavaScript is case-sensitive, soConsoleis an unknown name. - Since 2015, how often is a new ECMAScript edition released?Answer: Every year. TC39 publishes a new edition every June, named by year: ES2015, ES2016 … ES2026.
- Which test automation tool is not written for JavaScript/TypeScript?Answer: TestNG. TestNG is a Java testing framework. Playwright, Cypress and Jest are JavaScript tools.
💼 Interview Questions and Answers
Q1. What is JavaScript, and where does it run?
JavaScript is a high-level, dynamically typed, multi-paradigm language standardised as ECMAScript. It runs in every web browser (engines such as V8, SpiderMonkey and JavaScriptCore) and outside the browser in runtimes such as Node.js, Deno and Bun. The language is the same everywhere; the available APIs differ, for example document in browsers and fs in Node.js.
Q2. Is JavaScript interpreted or compiled?
Both. Engines start by interpreting the code (or compiling it quickly to bytecode) so it starts fast, then a just-in-time (JIT) compiler turns frequently run (“hot”) code into optimised machine code. V8 uses the Ignition interpreter and the TurboFan optimising compiler. So the honest answer is “JIT-compiled”, and there is no separate compile step for the developer.
Q3. What is the difference between JavaScript and ECMAScript?
ECMAScript is the specification (ECMA-262) published by Ecma International and evolved by the TC39 committee. JavaScript is the most popular implementation of that specification, plus host APIs such as the DOM or Node.js modules, which are not part of ECMAScript.
Q4. JavaScript is single-threaded. How can it handle many network requests at once?
Your JavaScript code runs on one thread, but the runtime (the browser or Node.js) performs slow I/O such as network and disk work in the background. When the work finishes, a callback is queued, and the event loop runs it when the call stack is empty. Promises and async/await are built on this model. You will study it in the Event Loop lesson.
Q5. Why should a tester learn JavaScript before Playwright or Cypress?
Test scripts are JavaScript or TypeScript programs. Locators, assertions and page objects all use variables, functions, objects, classes and especially async/await. Without those basics, flaky tests caused by a missing await or a wrong comparison are hard to debug. Knowing the language also lets you write helpers for test data, API calls and reports.
Q6. What is the difference between JavaScript and TypeScript?
TypeScript is a superset of JavaScript that adds static types. The TypeScript compiler checks types before the code runs and then removes them, producing plain JavaScript. Any JavaScript code is valid TypeScript. TypeScript catches mistakes earlier and gives better autocomplete, which is why most Playwright projects use it.
❓ Frequently Asked Questions
🤔 Is JavaScript hard to learn for beginners?
No. You can run JavaScript in any browser without installing anything, and the basic syntax is short. The harder parts, such as asynchronous code and this, come later in this course after you know the basics.
🤔 Is JavaScript the same as Java?
No. They are different languages. The name was a marketing decision in 1995. Java is statically typed and runs on the JVM; JavaScript is dynamically typed and runs in browsers and Node.js.
🤔 Do I need to learn HTML and CSS before JavaScript?
Not for this course. Modules 1 to 11 run JavaScript in Node.js. Basic HTML helps for Module 12 (DOM and browser), which explains the HTML it uses.
🤔 Which JavaScript version should I learn in 2026?
Learn modern JavaScript (ES2015 and later, up to ES2026). All current browsers and Node.js 22 or later support it, and that is what this course teaches.
🏁 Summary
- JavaScript is a high-level, dynamically typed, multi-paradigm language that runs in every browser and, with Node.js, outside the browser.
- ECMAScript is the standard; TC39 releases a new edition every year, and ES2026 is the current one.
- Engines such as V8 run the code; runtimes such as Chrome and Node.js add their own APIs.
- JavaScript powers web apps, servers, CLI tools and test frameworks such as Playwright and Cypress.
- It is case-sensitive:
ReferenceErrorusually means a misspelled or wrongly capitalised name.
Next, continue with Lesson 2: Install Node.js and VS Code.
🎬 Watch JavaScript and automation tutorials on YouTube!
Subscribe to SqaToolsByDY • Practice on sqatools.in