What is the TypeScript equivalent of this JavaScript?
(function() {
/* code here */
})();
I have tried this
() => {
/* code here */
}
But this produces
(function() {
/* code here */
});
I need the extra set of parenthesis at the end to perform an execution of the anonymous function.
(() => {
/* code here */
})();
or simply use the JavaScript (which is equally valid TypeScript)
(function() {
/* code here */
})();
... depending whether you want to capture this
using the fat arrow.
Playground.
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