Skip to content

Instantly share code, notes, and snippets.

@Ncreshon
Created June 10, 2017 18:20
Show Gist options
  • Select an option

  • Save Ncreshon/eba94e18aeec99780e6c5c584b138e85 to your computer and use it in GitHub Desktop.

Select an option

Save Ncreshon/eba94e18aeec99780e6c5c584b138e85 to your computer and use it in GitHub Desktop.
JS BinVariables, Const, Let// source https://jsbin.com/hoqace
/*
* Variables:
*
*Variables are continers used to hold values. Thes values can be any
*data type. Variables can be changed once they are defined.
*
* To create a variable we use the keyword var followed by the name .
*/
var firstName;
console.log(firstName);
/* In the above example the variable firstName was declared. At this point
* if firstName was to be called it's value would be undefined. A value for
* firstName has not been set
*/
firstName = "Harley";
console.log(firstName);
/* Now firstName has been initialized. We have given it the value "Harley"
*Now if firstName is called it will return a value of "Harley"
* Variables can be reassigned using the same form as the above example.
*Reassigning a variable changes the value stored inside of it.
*/
firstName = "Christian";
console.log(firstName);
/* The value of firstName is now "Christian" since it has been reassigned.
*When reassigned a varible in Javascript you do not have to keep it the same datatype.
*
*Conts:
*Conts are constant. They can not be reassigned.
*/
//Const hisName = "Lloyd"; //
//hisName = "Quentin";//
/* When consoled "Lloyd" would still be the value for hisName.
*
*Let:
*Let is blocked scoped. It can be reassigned.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment