start learning
Image 1

Javascript Data

In JavaScript, Data refers to the values that are stored and manipulated within a program. It represents the information that is processed, stored, and used to perform various operations. Data in JavaScript can have different types, such as numbers, strings, booleans, objects, arrays, null, and undefined.

Data definition involves declaring a variable and assigning a value to it. The variable acts as a named container that holds the data. It allows you to refer to and manipulate the data throughout your program.

examples of data definition in JavaScript along with explanations :


let age = 25;

In this example, the variable age is assigned the value 25, which represents a numeric data type.


let name = "John Doe";

The variable name is assigned the string value "John Doe" , which represents textual data.


let isActive = true;

The variable isActive is assigned the boolean value true, which represents a logical state.


let value = null;

The variable value is assigned the value null, indicating the intentional absence of an object value.


  let data;

The variable data is declared without an initial value, resulting in an undefined value.


let person = {
  name: "John",
  age: 25,
  isActive: true

The variable person is assigned an object containing key-value pairs representing properties of a person.


function sayHello() {

The sayHello function represents a reusable block of code that outputs "Hello!" when called.


let numbers = [1, 2, 3, 4, 5];
let fruits = ["apple", "banana", "orange"];

The variable numbers is assigned an array of numeric values, while fruits contains an array of string values.