Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta name="description" content="[Description and examples of variables.]">
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width">
- <title>Variables, Constants, and Lets</title>
- </head>
- <body>
- <script id="jsbin-javascript">
- /*
- Variables, Constants, and Lets
- Variables, constants, and lets hold values in memory so
- that they can be used elsewhere in applications. The value
- and data type of variables can be changed. As well, they
- can be local or global. On the contrary, constants may not
- change once they are assigned, although they are restricted
- to the code block in which they are assigned and declared.
- Lets are similar to variables and constants. They may change
- value, but they are limited to the scope in which they are
- declared and assigned.
- Variables are declared with the keyword var:
- */
- var firstName;
- var favNumber;
- /*
- At this point, the variable is undefined because it has not
- been initialized/assigned.
- Best practice is to both declare and assign a variable
- at the same time:
- */
- var firstName = "Daniela";
- var favNumber = 7;
- /*
- Variables may be simple values like numbers, strings, and
- booleans, as well as arrays or objects.
- Constants may also be simple values, as well as arrays or objects.
- As simple values, they may never change within their scopt.
- Arrays or objects that are constants may be modified, but not reassigned.
- Lets may be reassigned within scope, but may not be global variables.
- */
- </script>
- <script id="jsbin-source-javascript" type="text/javascript">/*
- Variables, Constants, and Lets
- Variables, constants, and lets hold values in memory so
- that they can be used elsewhere in applications. The value
- and data type of variables can be changed. As well, they
- can be local or global. On the contrary, constants may not
- change once they are assigned, although they are restricted
- to the code block in which they are assigned and declared.
- Lets are similar to variables and constants. They may change
- value, but they are limited to the scope in which they are
- declared and assigned.
- Variables are declared with the keyword var:
- */
- var firstName;
- var favNumber;
- /*
- At this point, the variable is undefined because it has not
- been initialized/assigned.
- Best practice is to both declare and assign a variable
- at the same time:
- */
- var firstName = "Daniela";
- var favNumber = 7;
- /*
- Variables may be simple values like numbers, strings, and
- booleans, as well as arrays or objects.
- Constants may also be simple values, as well as arrays or objects.
- As simple values, they may never change within their scopt.
- Arrays or objects that are constants may be modified, but not reassigned.
- Lets may be reassigned within scope, but may not be global variables.
- */
- </script></body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement