coffee scrip layzy function implementation
- by bbz
I would like to something like this in JavaScript
var init = function () {
// do some stuff once
var once = true
// overwrite the function
init = function () {
console.log(once)
}
}
CoffeeScript adds another local var init to the initial init so the second init doesn't overwrite the first one
var init = function () {
var init //automatically declared by coffeescript
// do some stuff once
var once = true
// overwrite the function
init = function () {
console.log(once)
}
}
Some tips for solutions / workarounds would be greatly appreciated.