Last active
August 29, 2015 14:17
-
-
Save meadsteve/f00cbf6ff62359d3e5e5 to your computer and use it in GitHub Desktop.
js-private-type-info
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
type_with_secrets = (function() { | |
var secret_type_number = 0; | |
var exported_type = function(){}; | |
exported_type.prototype.increment_secret = function() { secret_type_number += 1;}; | |
exported_type.prototype.get_secret = function() { return secret_type_number;}; | |
return exported_type; | |
})(); | |
var a = new type_with_secrets(); | |
var b = new type_with_secrets(); | |
a.increment_secret(); | |
b.increment_secret(); | |
a.increment_secret(); | |
console.log("Hopefully this number will be 3: " + b.get_secret()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment