Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save Ncreshon/300c770ed542d44eb31ad15533e6df8b to your computer and use it in GitHub Desktop.
JS Bin Variables, Const, Let // source https://jsbin.com/hoqace
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Variables, Const, Let">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<title>Variables, Let, and Const</title>
<script id="jsbin-javascript">
/*
* 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.
*/
</script>
<script id="jsbin-source-javascript" type="text/javascript">/*
* 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.
*/</script></body>
</html>
/*
* 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