Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta name="description" content="Variables">
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width">
- <title>JS Bin</title>
- </head>
- <body>
- <script id="jsbin-javascript">
- /* Variables
- *
- * 1. Definition/Function
- *
- * JavaScript variables are containers for storing data values.
- * In order to hold things in memory during the life-cycle of a program, we can use variables.
- * Variables are named identifiers that can point to the values of a particular type (e.g., a Number, String, Boolean, Array, object).
- * Variables are named as such because once created, we can change their value
- * and type of value.
- *
- *
- * 2. Creating the Variable
- *
- * In order to create a variable, we use the keyword, var, followed by a name for our variable.
- *
- * 3. Declaring the Variable
- *
- * There are 2 phases of using variables: declaration of the variable and initialization (or assignment) of the variable.
- * These unique names are called identifiers.
- * Identifiers can be short names (like x and y) or more descriptive names (age, sum, totalVolume).
- * The general rules for constructing names for variables (unique identifiers) are:
- * Names can contain letters, digits, underscores, and dollar signs.
- * Names must begin with a letter
- * Names can also begin with $ and _ (but we will not use it in this tutorial)
- * Names are case sensitive (y and Y are different variables)
- * Reserved words (like JavaScript keywords) cannot be used as names
- /*
- // 1. Declaration //
- var myName;
- /* At the declaration phase, the varialbe myName is undefined because we have not initialized it to anything.
- */
- console.log(myName); //prints ==> undefined
- // 3. Initialization or Assignment //
- myName = "Rachel"; //prints ==> Rachel
- // 4. Re-Assignment //
- /* Variables can be reassigned as exemplified below: */
- var myVariable = 1;
- var myVariable = true;
- myVariable = "someString";
- </script>
- <script id="jsbin-source-javascript" type="text/javascript">/* Variables
- *
- * 1. Definition/Function
- *
- * JavaScript variables are containers for storing data values.
- * In order to hold things in memory during the life-cycle of a program, we can use variables.
- * Variables are named identifiers that can point to the values of a particular type (e.g., a Number, String, Boolean, Array, object).
- * Variables are named as such because once created, we can change their value
- * and type of value.
- *
- *
- * 2. Creating the Variable
- *
- * In order to create a variable, we use the keyword, var, followed by a name for our variable.
- *
- * 3. Declaring the Variable
- *
- * There are 2 phases of using variables: declaration of the variable and initialization (or assignment) of the variable.
- * These unique names are called identifiers.
- * Identifiers can be short names (like x and y) or more descriptive names (age, sum, totalVolume).
- * The general rules for constructing names for variables (unique identifiers) are:
- * Names can contain letters, digits, underscores, and dollar signs.
- * Names must begin with a letter
- * Names can also begin with $ and _ (but we will not use it in this tutorial)
- * Names are case sensitive (y and Y are different variables)
- * Reserved words (like JavaScript keywords) cannot be used as names
- /*
- // 1. Declaration //
- var myName;
- /* At the declaration phase, the varialbe myName is undefined because we have not initialized it to anything.
- */
- console.log(myName); //prints ==> undefined
- // 3. Initialization or Assignment //
- myName = "Rachel"; //prints ==> Rachel
- // 4. Re-Assignment //
- /* Variables can be reassigned as exemplified below: */
- var myVariable = 1;
- var myVariable = true;
- myVariable = "someString";
- </script></body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement