Directly Calling Anonymous Function In Javascript

In Javascript we can define a anonymous function and directly call it like this:

((x) => x*2)(24)

In above we defined an anonymous function, which accept a parameter x and double its value then return. And we directly call it by passing argument 24 into it. And here is the output of the function:

We can see the function is directly called and the result 48 is the result.

My Github Page: https://github.com/liweinan

Powered by Jekyll and Theme by solid

If you have any question want to ask or find bugs regarding with my blog posts, please report it here:
https://github.com/liweinan/liweinan.github.io/issues