Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Introduction to JavaScript

Lesson 17 of 34 in the free Web Technologies notes on Siksha Sarovar, written by Rohit Jangra.

Introduction to JavaScript

What is JavaScript?

JavaScript (JS) is a lightweight, interpreted, dynamic scripting language used to make web pages interactive. It runs in the browser and also on the server (via Node.js).

Key Features

  • Interpreted (no compilation)
  • Dynamically typed
  • Object-based (prototype inheritance)
  • Event-driven and asynchronous
  • Runs in every browser

Including JavaScript in HTML

<!-- Inline JS (not recommended) -->
<button onclick="alert('Hello!')">Click</button>

<!-- Internal script -->
<script>
  console.log('Hello from internal script');
</script>

<!-- External script (recommended) -->
<script src="app.js" defer></script>
<!-- defer: runs after HTML is parsed -->
<!-- async: runs as soon as downloaded -->

JavaScript Output

console.log("Debug message");       // Browser console
console.warn("Warning");
console.error("Error message");
alert("Popup message");             // Alert box
document.write("Write to page");    // Directly to page
document.getElementById("out").textContent = "Hello!"; // DOM

Hello World Example

// Single line comment

/*
  Multi-line comment
*/

console.log("Hello, World!");

// Variables
let name = "Alice";
const PI = 3.14159;
var old = "avoid var";

// Basic operations
let sum = 10 + 5;
let greeting = "Hello, " + name + "!";
console.log(greeting); // Hello, Alice!

JavaScript vs Other Languages

FeatureJavaScriptPythonJava
TypingDynamicDynamicStatic
CompilationInterpretedInterpretedCompiled
Primary useWebGeneralEnterprise
Runs inBrowser/NodeOSJVM

JavaScript Versions (ECMAScript)

VersionYearKey Features
ES52009use strict, JSON
ES6/ES20152015let/const, arrow functions, classes, Promises
ES20172017async/await
ES20202020Optional chaining, nullish coalescing

Developer Tools

Open browser DevTools with F12 or Right-click → Inspect:

  • Console: Run JS, see errors/logs
  • Sources: Debug JS code
  • Network: Monitor HTTP requests
  • Elements: Inspect HTML/CSS
Key Takeaway: JavaScript is the language of the Web, making pages dynamic and interactive. Use external scripts with defer for best performance and console.log for debugging.