Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.54 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>Variables</title>
  8. </head>
  9. <body>
  10.  
  11. /*
  12. *VARIABLES
  13. *
  14. *0. Just like in Algebra, variables are placeholders.
  15. Variables hold the place of a value that can be defined
  16. and reassigned as needed. These values can include numbers,
  17. strings, boolean, functions and more.
  18. *
  19. *1. To create a variable we use the keyword varfollowed by a name. Usually best to to name the
  20. variable something that closely describes what the
  21. variable represents.
  22. *
  23. *2. The 2 phases of using variables are: declaration and
  24. initialization (or assisgnment).
  25. */
  26.  
  27. // 1. declaration //
  28. var myName;
  29.  
  30. /*
  31. *At declaration phase, the variable myName is undefined
  32. because we have NOT initialized it to anything
  33. */
  34.  
  35. console.log(myName); //prints => undefined
  36.  
  37. // 2. Initialization or assignment //
  38. myName = "john";
  39. console.log(myName); // prints => john
  40.  
  41. // 3. Re-assignment //
  42. myName = "bob";
  43. console.log(myName); // prints => bob
  44.  
  45. /* NOTE: We can assign and re-assign anything to a variable -
  46. we cannot do this with constants */
  47.  
  48. var myVarible = 1;
  49. var myVarible = true;
  50.  
  51.  
  52.  
  53.  
  54. <script id="jsbin-javascript">
  55. /*
  56. *VARIABLES
  57. *
  58. *0. Just like in Algebra, variables are placeholders.
  59. Variables hold the place of a value that can be defined
  60. and reassigned as needed. These values can include numbers,
  61. strings, boolean, functions and more.
  62. *
  63. *1. To create a variable we use the keyword varfollowed by a name. Usually best to to name the
  64. variable something that closely describes what the
  65. variable represents.
  66. *
  67. *2. The 2 phases of using variables are: declaration and
  68. initialization (or assisgnment).
  69. */
  70.  
  71. // 1. declaration //
  72. var myName;
  73.  
  74. /*
  75. *At declaration phase, the variable myName is undefined
  76. because we have NOT initialized it to anything
  77. */
  78.  
  79. console.log(myName); //prints => undefined
  80.  
  81. // 2. Initialization or assignment //
  82. myName = "john";
  83. console.log(myName); // prints => john
  84.  
  85. // 3. Re-assignment //
  86. myName = "bob";
  87. console.log(myName); // prints => bob
  88. /* NOTE: We can assign and re-assign anything to a variable -
  89. we cannot do this with constants */
  90. var myVarible = 1;
  91. var myVarible = true;
  92. myVariable = "someString";
  93. </script>
  94.  
  95.  
  96.  
  97. <script id="jsbin-source-javascript" type="text/javascript">/*
  98. *VARIABLES
  99. *
  100. *0. Just like in Algebra, variables are placeholders.
  101. Variables hold the place of a value that can be defined
  102. and reassigned as needed. These values can include numbers,
  103. strings, boolean, functions and more.
  104. *
  105. *1. To create a variable we use the keyword varfollowed by a name. Usually best to to name the
  106. variable something that closely describes what the
  107. variable represents.
  108. *
  109. *2. The 2 phases of using variables are: declaration and
  110. initialization (or assisgnment).
  111. */
  112.  
  113. // 1. declaration //
  114. var myName;
  115.  
  116. /*
  117. *At declaration phase, the variable myName is undefined
  118. because we have NOT initialized it to anything
  119. */
  120.  
  121. console.log(myName); //prints => undefined
  122.  
  123. // 2. Initialization or assignment //
  124. myName = "john";
  125. console.log(myName); // prints => john
  126.  
  127. // 3. Re-assignment //
  128. myName = "bob";
  129. console.log(myName); // prints => bob
  130. /* NOTE: We can assign and re-assign anything to a variable -
  131. we cannot do this with constants */
  132. var myVarible = 1;
  133. var myVarible = true;
  134. myVariable = "someString";
  135. </script></body>
  136. </html>
  137. jsbin.nefiqi.js
  138. /*
  139. *VARIABLES
  140. *
  141. *0. Just like in Algebra, variables are placeholders.
  142. Variables hold the place of a value that can be defined
  143. and reassigned as needed. These values can include numbers,
  144. strings, boolean, functions and more.
  145. *
  146. *1. To create a variable we use the keyword varfollowed by a name. Usually best to to name the
  147. variable something that closely describes what the
  148. variable represents.
  149. *
  150. *2. The 2 phases of using variables are: declaration and
  151. initialization (or assisgnment).
  152. */
  153.  
  154. // 1. declaration //
  155. var myName;
  156.  
  157. /*
  158. *At declaration phase, the variable myName is undefined
  159. because we have NOT initialized it to anything
  160. */
  161.  
  162. console.log(myName); //prints => undefined
  163.  
  164. // 2. Initialization or assignment //
  165. myName = "john";
  166. console.log(myName); // prints => john
  167.  
  168. // 3. Re-assignment //
  169. myName = "bob";
  170. console.log(myName); // prints => bob
  171.  
  172. /* NOTE: We can assign and re-assign anything to a variable -
  173. we cannot do this with constants */
  174.  
  175. var myVarible = 1;
  176. var myVarible = true;
  177. myVariable = "someString";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement