Created
May 27, 2014 16:12
-
-
Save clamstew/8191fbfb68070b720c28 to your computer and use it in GitHub Desktop.
A small maker nap constructor to ponder
This file contains hidden or 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 lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<title>My Title</title> | |
<meta name="description" content=""> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body> | |
<!-- body goes here --> | |
<script type="text/javascript"> | |
var Maker = function() { | |
var naps = 0; | |
nap = 6; | |
this.getNaps = function() { | |
return naps; | |
}; | |
this.nap = function() { | |
naps += 1; | |
}; | |
}; | |
var maker1 = new Maker(); | |
maker1.nap(); | |
console.log("We're able to access the internal nap count", maker1.getNaps() == 1 ); | |
console.log("And the private data is inaccessible to us.", Maker.naps === undefined ); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment