Assignment
operator is used to assign value to a variable. Since JavaScript is weakly
typed language, you can assign any type of value to a variable.
Syntax
var
variableName = value;
variables.html
<!DOCTYPE html> <html> <head> <title>Variables</title> </head> <body> <script type="text/javascript"> var a = 10; document.write("Value of a is " + a + "<br />"); a = "Hello World"; // Assigning string document.write("Value of a is " + a + "<br />"); a = true; // Assigning boolean document.write("Value of a is " + a + "<br />"); a = 10.09; // Assigning number document.write("Value of a is " + a + "<br />"); </script> </body> </html>
No comments:
Post a Comment