New course! Every coder should learn Generative AI!
Try a free lesson+ 1
Parentheses in JavaScript
can anyone explain why the closing parentheses are at the end, not inside the curly brackets. let num = [1,2,3,4]; num.forEach(function (e) { console.log(e); });
4 Answers
+ 3
the functions wrapped with parenthesis are called “Immediately Invoked Function Expressions" or "Self Executing Functions.
+ 1
It is inside and also outside.
It started outside curly brace so should close outside curly brace.
it just added a function in ( here ); which aplied to every num element...
+ 1
thanks..
0
Vaibhav Singh thank you for adding..