Parentheses in JavaScript | Sololearn: Learn to code for FREE!
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); });

25th Mar 2022, 1:49 PM
Dec Fathani
Dec Fathani - avatar
4 Answers
+ 3
the functions wrapped with parenthesis are called “Immediately Invoked Function Expressions" or "Self Executing Functions.
26th Mar 2022, 3:57 AM
Vaibhav
Vaibhav - avatar
+ 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...
25th Mar 2022, 1:53 PM
Jayakrishna 🇮🇳
+ 1
thanks..
25th Mar 2022, 2:12 PM
Dec Fathani
Dec Fathani - avatar
0
Vaibhav Singh thank you for adding..
26th Mar 2022, 5:12 AM
Dec Fathani
Dec Fathani - avatar