DEV Community

Cover image for Javascript
vishwa v
vishwa v

Posted on

Javascript

Introduction
JavaScript is the backbone of modern web development—it makes websites interactive, dynamic, and user‑friendly, going far beyond what HTML and CSS can do. It’s used both on the client side (in browsers) and server side (with Node.js), making it one of the most versatile programming languages today.

What is JavaScript?
Definition: A scripting language that allows developers to add interactivity, animations, and dynamic updates to web pages.

Origin: Initially called LiveScript, renamed to JavaScript in the mid‑1990s. Despite the name, it has no direct relation to Java.

Why Do We Use JavaScript?
Interactivity: Enables features like dropdown menus, image sliders, form validation, and interactive maps.

Dynamic Content: Updates parts of a webpage without reloading (e.g., live scores, chat apps).

Event Handling: Responds to user actions such as clicks, keystrokes, or mouse movements.

Asynchronous Operations: Fetches data from servers in the background (AJAX, APIs) without freezing the UI.

Cross‑Platform: Works in browsers, servers, and even mobile apps (via frameworks like React Native).

Rich Ecosystem: Popular frameworks like React, Angular, Vue.js simplify building complex applications.

How JavaScript Fits with HTML & CSS
Think of web technologies as a three‑layer cake:

HTML → Structure (headings, paragraphs, images).

CSS → Styling (colors, fonts, layouts).

JavaScript → Behavior (animations, interactivity, dynamic updates).

Datatypes

1)Primitive datatype

Number

Represents both integers and floating-point numbers.

let age = 25; 
let pi = 3.14; 
let infinity = Infinity;
Enter fullscreen mode Exit fullscreen mode

String

Text values enclosed in quotes.

let name = "Saran"; 
let greeting = `Hello, ${name}`;
Enter fullscreen mode Exit fullscreen mode

Boolean

Logical values: true or false.

let isLoggedIn = true;
Enter fullscreen mode Exit fullscreen mode

BigInt

For very large integers beyond the safe range of Number.

let big = 123456789012345678901234567890n;
Enter fullscreen mode Exit fullscreen mode

2)Non primitive datatype

Object

Collections of key-value pairs. Arrays, functions, and dates are all objects.

let person = { name: "Saran", age: 22 };
let arr = [1, 2, 3];
let today = new Date();
Enter fullscreen mode Exit fullscreen mode

Top comments (0)