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>Variables</title>
- </head>
- <body>
- /*
- *VARIABLES
- *
- *0. Just like in Algebra, variables are placeholders.
- Variables hold the place of a value that can be defined
- and reassigned as needed. These values can include numbers,
- strings, boolean, functions and more.
- *
- *1. To create a variable we use the keyword varfollowed by a name. Usually best to to name the
- variable something that closely describes what the
- variable represents.
- *
- *2. The 2 phases of using variables are: declaration and
- initialization (or assisgnment).
- */
- // 1. declaration //
- var myName;
- /*
- *At declaration phase, the variable myName is undefined
- because we have NOT initialized it to anything
- */
- console.log(myName); //prints => undefined
- // 2. Initialization or assignment //
- myName = "john";
- console.log(myName); // prints => john
- // 3. Re-assignment //
- myName = "bob";
- console.log(myName); // prints => bob
- /* NOTE: We can assign and re-assign anything to a variable -
- we cannot do this with constants */
- var myVarible = 1;
- var myVarible = true;
- <script id="jsbin-javascript">
- /*
- *VARIABLES
- *
- *0. Just like in Algebra, variables are placeholders.
- Variables hold the place of a value that can be defined
- and reassigned as needed. These values can include numbers,
- strings, boolean, functions and more.
- *
- *1. To create a variable we use the keyword varfollowed by a name. Usually best to to name the
- variable something that closely describes what the
- variable represents.
- *
- *2. The 2 phases of using variables are: declaration and
- initialization (or assisgnment).
- */
- // 1. declaration //
- var myName;
- /*
- *At declaration phase, the variable myName is undefined
- because we have NOT initialized it to anything
- */
- console.log(myName); //prints => undefined
- // 2. Initialization or assignment //
- myName = "john";
- console.log(myName); // prints => john
- // 3. Re-assignment //
- myName = "bob";
- console.log(myName); // prints => bob
- /* NOTE: We can assign and re-assign anything to a variable -
- we cannot do this with constants */
- var myVarible = 1;
- var myVarible = true;
- myVariable = "someString";
- </script>
- <script id="jsbin-source-javascript" type="text/javascript">/*
- *VARIABLES
- *
- *0. Just like in Algebra, variables are placeholders.
- Variables hold the place of a value that can be defined
- and reassigned as needed. These values can include numbers,
- strings, boolean, functions and more.
- *
- *1. To create a variable we use the keyword varfollowed by a name. Usually best to to name the
- variable something that closely describes what the
- variable represents.
- *
- *2. The 2 phases of using variables are: declaration and
- initialization (or assisgnment).
- */
- // 1. declaration //
- var myName;
- /*
- *At declaration phase, the variable myName is undefined
- because we have NOT initialized it to anything
- */
- console.log(myName); //prints => undefined
- // 2. Initialization or assignment //
- myName = "john";
- console.log(myName); // prints => john
- // 3. Re-assignment //
- myName = "bob";
- console.log(myName); // prints => bob
- /* NOTE: We can assign and re-assign anything to a variable -
- we cannot do this with constants */
- var myVarible = 1;
- var myVarible = true;
- myVariable = "someString";
- </script></body>
- </html>
- jsbin.nefiqi.js
- /*
- *VARIABLES
- *
- *0. Just like in Algebra, variables are placeholders.
- Variables hold the place of a value that can be defined
- and reassigned as needed. These values can include numbers,
- strings, boolean, functions and more.
- *
- *1. To create a variable we use the keyword varfollowed by a name. Usually best to to name the
- variable something that closely describes what the
- variable represents.
- *
- *2. The 2 phases of using variables are: declaration and
- initialization (or assisgnment).
- */
- // 1. declaration //
- var myName;
- /*
- *At declaration phase, the variable myName is undefined
- because we have NOT initialized it to anything
- */
- console.log(myName); //prints => undefined
- // 2. Initialization or assignment //
- myName = "john";
- console.log(myName); // prints => john
- // 3. Re-assignment //
- myName = "bob";
- console.log(myName); // prints => bob
- /* NOTE: We can assign and re-assign anything to a variable -
- we cannot do this with constants */
- var myVarible = 1;
- var myVarible = true;
- myVariable = "someString";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement