Skip to content

Instantly share code, notes, and snippets.

@MarkLavrynenko
Created March 28, 2015 15:02
Show Gist options
  • Save MarkLavrynenko/7806b0f1ae74b7193eb3 to your computer and use it in GitHub Desktop.
Save MarkLavrynenko/7806b0f1ae74b7193eb3 to your computer and use it in GitHub Desktop.
Js Symbols
function Schedule (pretend, real) {
this.morning = pretend["morning"];
this.evening = pretend["evening"]
var morning = Symbol("morning")
var evening = Symbol("evening")
this[morning] = real["morning"];
this[evening] = real["evening"];
this.printTruth = function(){
var truth = {
morning : this[morning],
evening : this[evening]
};
console.log(truth);
}
}
var pretend = {
morning : "sport",
evening : "family"
}
var real = {
morning : "vodka",
evening : "weed"
}
var daySchedule = new Schedule(pretend, real);
console.log(daySchedule)
daySchedule.printTruth()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment