Declaring variables and using them in JavaScript
Javascript Variable
JavaScript variables are containers for storing data values.
JavaScript variables can hold numbers like 100, and text values like "John".
The Assignment Operator
Here, the equal sign (=) is an "assignment" operator, not an "equal to" operator.
An example which Create a variable, assign a value to it, and display it:-
Result:
Description:
The Above program stores the string swift in a variable carName which later is displayed on a web browser through an alert
JavaScript variables are containers for storing data values.
JavaScript variables can hold numbers like 100, and text values like "John".
The Assignment Operator
<html> <body> <script> <!--Using Variables--> var carName = "Swift"; alert(carName); </script> </body> </html>
Result:
Alert Showing the value of the variable carName
Description:
The Above program stores the string swift in a variable carName which later is displayed on a web browser through an alert
Comments
Post a Comment