Monday, February 18, 2013

Javascript Basics Tutorial Part 2: Simple Function.

:In part 2 we are going to look into details of simple function declaration and its defination. We also look into function scope. Refer Part 1 for Objects and Array.

Function Scoping: Function can be called before it is defined. Look at below example.

Function : By default every function is like default constructor with inbuilt arguments.
We can also put debugger; to put a breakpoint and debug to step-in, step-out, step-over in vs 2010.

In short we can defined function with NO Input Argument but we can pass multiple input parameter values of any type while calling a function.
 
f2(17, 0.1, "Ninja", [], {});

function f2()
{
//Fn Responsibilty & Operations.
}
Interesting facts: Inside a function we can fetch the inputs values to the function through a array called arguments[].Internally it is stored in arguments[] array placeholder where we can reference and use the input values for the operations.




 Output

 
Post a Comment