A function can derive and return a value to that called program.
This way you could ignore to write the same code every time and create a modular structured programs.
You can derive your program into a number of functions, this way you manage your program very easily.
In this lesson you learn the basic function syntax, function definition, how to call empty function and arguments function, and finally access returns function value.
Function Syntax :
Before calling function, we need to declare function. After declare function, when you calling that function derive only that time.
In this example, name and salary are variables they are passed as an argument to empfun() function. Function body takes two arguments and one optional argument.
Browser Compatibility (optional arguments) :
And if you are passing three arguments, then use that passing value to derive this function.
No Arguments Function
You can write a function without passing any arguments. Function can derive itself with depend internal defined values.
Function returning a value
When you specify a function within another function, child function can access parents function scope. You can call the child function outside of parent function by following way,
Note: Here details of browser compatibility with version number may be this is bug and not supported. But recommended to always use latest Web browser.