Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta name="description" content="Variables">
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width">
  7. <title>JS Bin</title>
  8. </head>
  9. <body>
  10.  
  11. <script id="jsbin-javascript">
  12. /* Variables
  13. *
  14. * 1. Definition/Function
  15. *
  16. * JavaScript variables are containers for storing data values.
  17. * In order to hold things in memory during the life-cycle of a program, we can use variables.
  18. * Variables are named identifiers that can point to the values of a particular type (e.g., a Number, String, Boolean, Array, object).
  19. * Variables are named as such because once created, we can change their value
  20. * and type of value.
  21. *
  22. *
  23. * 2. Creating the Variable
  24. *
  25. * In order to create a variable, we use the keyword, var, followed by a name for our variable.
  26. *
  27. * 3. Declaring the Variable
  28. *
  29. * There are 2 phases of using variables: declaration of the variable and initialization (or assignment) of the variable.
  30. * These unique names are called identifiers.
  31. * Identifiers can be short names (like x and y) or more descriptive names (age, sum, totalVolume).
  32. * The general rules for constructing names for variables (unique identifiers) are:
  33. * Names can contain letters, digits, underscores, and dollar signs.
  34. * Names must begin with a letter
  35. * Names can also begin with $ and _ (but we will not use it in this tutorial)
  36. * Names are case sensitive (y and Y are different variables)
  37. * Reserved words (like JavaScript keywords) cannot be used as names
  38. /*
  39. // 1. Declaration //
  40. var myName;
  41. /* At the declaration phase, the varialbe myName is undefined because we have not initialized it to anything.
  42. */
  43. console.log(myName); //prints ==> undefined
  44. // 3. Initialization or Assignment //
  45. myName = "Rachel"; //prints ==> Rachel
  46.  
  47. // 4. Re-Assignment //
  48. /* Variables can be reassigned as exemplified below: */
  49. var myVariable = 1;
  50. var myVariable = true;
  51. myVariable = "someString";
  52. </script>
  53.  
  54.  
  55.  
  56. <script id="jsbin-source-javascript" type="text/javascript">/* Variables
  57. *
  58. * 1. Definition/Function
  59. *
  60. * JavaScript variables are containers for storing data values.
  61. * In order to hold things in memory during the life-cycle of a program, we can use variables.
  62. * Variables are named identifiers that can point to the values of a particular type (e.g., a Number, String, Boolean, Array, object).
  63. * Variables are named as such because once created, we can change their value
  64. * and type of value.
  65. *
  66. *
  67. * 2. Creating the Variable
  68. *
  69. * In order to create a variable, we use the keyword, var, followed by a name for our variable.
  70. *
  71. * 3. Declaring the Variable
  72. *
  73. * There are 2 phases of using variables: declaration of the variable and initialization (or assignment) of the variable.
  74. * These unique names are called identifiers.
  75. * Identifiers can be short names (like x and y) or more descriptive names (age, sum, totalVolume).
  76. * The general rules for constructing names for variables (unique identifiers) are:
  77. * Names can contain letters, digits, underscores, and dollar signs.
  78. * Names must begin with a letter
  79. * Names can also begin with $ and _ (but we will not use it in this tutorial)
  80. * Names are case sensitive (y and Y are different variables)
  81. * Reserved words (like JavaScript keywords) cannot be used as names
  82. /*
  83. // 1. Declaration //
  84. var myName;
  85. /* At the declaration phase, the varialbe myName is undefined because we have not initialized it to anything.
  86. */
  87. console.log(myName); //prints ==> undefined
  88. // 3. Initialization or Assignment //
  89. myName = "Rachel"; //prints ==> Rachel
  90.  
  91. // 4. Re-Assignment //
  92. /* Variables can be reassigned as exemplified below: */
  93. var myVariable = 1;
  94. var myVariable = true;
  95. myVariable = "someString";
  96. </script></body>
  97. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement