Skip to content

Instantly share code, notes, and snippets.

Created August 11, 2016 23:33
Show Gist options
  • Save anonymous/0aa4d75a411dfc1a871f9fe1e2193a47 to your computer and use it in GitHub Desktop.
Save anonymous/0aa4d75a411dfc1a871f9fe1e2193a47 to your computer and use it in GitHub Desktop.
explains instances // source http://jsbin.com/huqugu
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>explains instances</title>
</head>
<body>
<script id="jsbin-javascript">
function vehicle(color){
this.color = color;
}
//car is an instance of the vehicle constructor
// the new keyword is creating a new instance aka object
var car = new vehicle('red');
console.log(car.color);
</script>
<script id="jsbin-source-javascript" type="text/javascript">function vehicle(color){
this.color = color;
}
//car is an instance of the vehicle constructor
// the new keyword is creating a new instance aka object
var car = new vehicle('red');
console.log(car.color);</script></body>
</html>
function vehicle(color){
this.color = color;
}
//car is an instance of the vehicle constructor
// the new keyword is creating a new instance aka object
var car = new vehicle('red');
console.log(car.color);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment