
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
What is the purpose of the var keyword in JavaScript?
Like many other programming languages, JavaScript has variables. Variables can be thought of as named containers. You can place data into these containers and then refer to the data simply by naming the container. The var keyword is used to declare variables in JavaScript.
Before you use a variable in a JavaScript program, you must declare it. Variables are declared with the var keyword as follows.
<script> <!-- var money; var name; //--> </script>
You can also declare multiple variables with the same var keyword as follows −
<script> <!-- var money, name; //--> </script>
Storing a value in a variable is called variable initialization. You can do variable initialization at the time of variable creation or at a later point in time when you need that variable.
- Related Articles
- What does the keyword var do in C#?
- What is the purpose of new Boolean() in JavaScript?
- What is the yield keyword in JavaScript?
- What is the usage of yield keyword in JavaScript?
- What is the purpose of a self-executing function in JavaScript?
- What is the difference between: var functionName = function() {} and function functionName() {} in Javascript
- What is the 'new' keyword in JavaScript?
- What is the use of the VAR element type in HTML?
- What does the operator || do in a var statement in JavaScript?
- What is the purpose of wrapping whole JavaScript files in anonymous functions?
- Difference between var keyword and short declaration operator in Golang
- What is the purpose of the `//` operator in python?
- What is the purpose of interfaces in java?
- What is the purpose of VOLUME in Dockerfile?
- What is the purpose of ‘is’ operator in C#?

Advertisements