Created
September 26, 2015 17:16
-
-
Save anonymous/991477c8502c82f06ff5 to your computer and use it in GitHub Desktop.
HW W1D4 - Variables HW W1D4 // source http://jsbin.com/qicites
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="HW W1D4"> | |
<meta charset="utf-8"> | |
<title>HW W1D4 - Variables</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
/* | |
* VARIABLES: | |
* | |
* 0. To hold things in memory during the life-cycle of a program, we can use variables. Variables | |
* are named identifiers that can point to values of a particular type, like a Number, String, | |
* Boolean, Array, Object or another data-type. Variables are called so because once created, we | |
* can CHANGE the value (and type of value) to which they point. | |
* | |
* 1. To create a variable we use the keyword, var, followed by a name (id or alias) for our | |
* variable. | |
* | |
* 2. There are 2 phases of using variables: declaration and initialization (or assignment). | |
*/ | |
// 1. declaration // | |
var myName; | |
/* | |
* At the 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 = 'Maxwell'; | |
console.log(myName); // prints => john | |
// 3. re-assignment // | |
myName = 'Jordan'; | |
console.log(myName); // prints => bob | |
// NOTE: We can assign and re-assign anything to a variable - we cannot do this with constants // | |
var myVariable = 1; | |
var myVariable = true; | |
myVariable = "someString"; | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">/* | |
* VARIABLES: | |
* | |
* 0. To hold things in memory during the life-cycle of a program, we can use variables. Variables | |
* are named identifiers that can point to values of a particular type, like a Number, String, | |
* Boolean, Array, Object or another data-type. Variables are called so because once created, we | |
* can CHANGE the value (and type of value) to which they point. | |
* | |
* 1. To create a variable we use the keyword, var, followed by a name (id or alias) for our | |
* variable. | |
* | |
* 2. There are 2 phases of using variables: declaration and initialization (or assignment). | |
*/ | |
// 1. declaration // | |
var myName; | |
/* | |
* At the 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 = 'Maxwell'; | |
console.log(myName); // prints => john | |
// 3. re-assignment // | |
myName = 'Jordan'; | |
console.log(myName); // prints => bob | |
// NOTE: We can assign and re-assign anything to a variable - we cannot do this with constants // | |
var myVariable = 1; | |
var myVariable = true; | |
myVariable = "someString";</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* VARIABLES: | |
* | |
* 0. To hold things in memory during the life-cycle of a program, we can use variables. Variables | |
* are named identifiers that can point to values of a particular type, like a Number, String, | |
* Boolean, Array, Object or another data-type. Variables are called so because once created, we | |
* can CHANGE the value (and type of value) to which they point. | |
* | |
* 1. To create a variable we use the keyword, var, followed by a name (id or alias) for our | |
* variable. | |
* | |
* 2. There are 2 phases of using variables: declaration and initialization (or assignment). | |
*/ | |
// 1. declaration // | |
var myName; | |
/* | |
* At the 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 = 'Maxwell'; | |
console.log(myName); // prints => john | |
// 3. re-assignment // | |
myName = 'Jordan'; | |
console.log(myName); // prints => bob | |
// NOTE: We can assign and re-assign anything to a variable - we cannot do this with constants // | |
var myVariable = 1; | |
var myVariable = true; | |
myVariable = "someString"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment