Created
June 26, 2018 20:01
-
-
Save parambirs/cf5775a2ec7131f52b25f0946951600e to your computer and use it in GitHub Desktop.
Singleton in JavaScript
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
'use strict'; | |
let lime = new function() { | |
this.type = 'Mexican lime'; | |
this.color = 'green'; | |
this.getInformation = function() { | |
return 'This ' + this.type + ' is ' + this.color + '.'; | |
}; | |
} | |
console.log(lime.getInformation()); | |
lime.color = 'yellow'; | |
console.log(lime.getInformation()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment