Last active
September 25, 2016 04:09
-
-
Save erikroyall/d04aff1cc1e7786567dd3f83908aaf3b to your computer and use it in GitHub Desktop.
Sweet.js for clone Potato => Object.create(Potato)
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
syntax clone = function (ctx) { | |
let ident = ctx.next().value; | |
return #`Object.create(${ident})`; | |
} | |
var Potato = { | |
meaningOfLife: 42 | |
}; | |
var potato = clone Potato; | |
potato.meaningOfLife; // 42 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment