Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta name="description" content="[Description and examples of variables.]">
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width">
  7. <title>Variables, Constants, and Lets</title>
  8. </head>
  9. <body>
  10.  
  11. <script id="jsbin-javascript">
  12. /*
  13.  
  14. Variables, Constants, and Lets
  15.  
  16. Variables, constants, and lets hold values in memory so
  17. that they can be used elsewhere in applications. The value
  18. and data type of variables can be changed. As well, they
  19. can be local or global. On the contrary, constants may not
  20. change once they are assigned, although they are restricted
  21. to the code block in which they are assigned and declared.
  22. Lets are similar to variables and constants. They may change
  23. value, but they are limited to the scope in which they are
  24. declared and assigned.
  25.  
  26. Variables are declared with the keyword var:
  27. */
  28. var firstName;
  29. var favNumber;
  30. /*
  31. At this point, the variable is undefined because it has not
  32. been initialized/assigned.
  33.  
  34. Best practice is to both declare and assign a variable
  35. at the same time:
  36. */
  37. var firstName = "Daniela";
  38. var favNumber = 7;
  39. /*
  40. Variables may be simple values like numbers, strings, and
  41. booleans, as well as arrays or objects.
  42.  
  43. Constants may also be simple values, as well as arrays or objects.
  44. As simple values, they may never change within their scopt.
  45. Arrays or objects that are constants may be modified, but not reassigned.
  46. Lets may be reassigned within scope, but may not be global variables.
  47.  
  48. */
  49. </script>
  50.  
  51.  
  52.  
  53. <script id="jsbin-source-javascript" type="text/javascript">/*
  54.  
  55. Variables, Constants, and Lets
  56.  
  57. Variables, constants, and lets hold values in memory so
  58. that they can be used elsewhere in applications. The value
  59. and data type of variables can be changed. As well, they
  60. can be local or global. On the contrary, constants may not
  61. change once they are assigned, although they are restricted
  62. to the code block in which they are assigned and declared.
  63. Lets are similar to variables and constants. They may change
  64. value, but they are limited to the scope in which they are
  65. declared and assigned.
  66.  
  67. Variables are declared with the keyword var:
  68. */
  69. var firstName;
  70. var favNumber;
  71. /*
  72. At this point, the variable is undefined because it has not
  73. been initialized/assigned.
  74.  
  75. Best practice is to both declare and assign a variable
  76. at the same time:
  77. */
  78. var firstName = "Daniela";
  79. var favNumber = 7;
  80. /*
  81. Variables may be simple values like numbers, strings, and
  82. booleans, as well as arrays or objects.
  83.  
  84. Constants may also be simple values, as well as arrays or objects.
  85. As simple values, they may never change within their scopt.
  86. Arrays or objects that are constants may be modified, but not reassigned.
  87. Lets may be reassigned within scope, but may not be global variables.
  88.  
  89. */
  90. </script></body>
  91. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement