+ 3

Calling a function

What is the difference between a function called with the " () braces " and a call with just its name without a braces.

4th Dec 2020, 11:46 AM
ALABI TIMOTHY
ALABI TIMOTHY - avatar
3 Antworten
+ 5
Functions are treated as objects. So, like we have an object of a class, functions are also objects. So, if you mention only the name, you are accessing the function object, but if you add (), the function gets called, and it performs its task. Ex- let sum() be a function to add 2 nums, so x = sum, then x gets assign that sum object, so we can use x(), and it performs the same thing as sum(). Its simple object operation. I hope u get it.
4th Dec 2020, 12:41 PM
Charitra
Charitra - avatar
0
Thanks a bunch
8th Dec 2020, 8:18 PM
ALABI TIMOTHY
ALABI TIMOTHY - avatar