Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does (foo) in function(args){ ... }(foo) mean?

Tags:

javascript

I've been struggling with Javascript objects.

What does (foo) in function(args){ ... }(foo) mean?

like image 667
Finwood Avatar asked Jan 17 '26 16:01

Finwood


1 Answers

You are declaring a function then right after that you call it. you could do it in 2 steps :

function f(args){}

f(foo);

Single step and anonymous :

(function(args){})(foo);
like image 60
TecHunter Avatar answered Jan 20 '26 04:01

TecHunter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!