JavaScript Variable
A variable in JavaScript is a named container that stores a value. It can be created using the var, let, or const.
Syntax:
let variable_name = value;
const variable_name = value;
Example: In this example, age is a variable that holds a numeric value and name is a variable holding the string value.
Javascript
let age = 35; const name = 'Kumar' ; console.log( "Age: " + age); console.log( "Name: " + name); |
Output:
Age: 35
Name: Kumar
Difference Between Variables and Objects in JavaScript
The variables and objects are fundamental concepts but they serve different purposes. The Variables are used to store data values while objects are used to group related data and functions into a single entity.
Contact Us