Could someone show me how to immediately invoke a function in CoffeeScript. I'm trying to accomplish something similar to this JS object literal.
WEBAPP = {
maxHeight : function(){
/* Calc stuff n' stuff */
WEBAPP.maxHeight = /* Calculated value */
}(),
someProperty : ''
/* ... */
}
Is it possible or what are the workarounds?
There is do
:
WEBAPP =
maxheight: do -> 1+1
someProperty: ''
Which compiles to
var WEBAPP;
WEBAPP = {
maxheight: (function() {
return 1 + 1;
})(),
someProperty: ''
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With