2.4 Functions
2.4 Functions
Module :II
Module name :JavaScript Fundamentals
Topic :Functions
Faculty : Dr. S. Karthikeyini, AP/M.Tech CSE
PHP & JS FRAMEWORK 2
FUNCTIONS
PHP & JS FRAMEWORK 3
TYPES
PHP & JS FRAMEWORK 4
NAMED FUNCTION
PHP & JS FRAMEWORK 5
NUMBER
PHP & JS FRAMEWORK 6
NUMBER
7
Feature Description
CONSTRUCTOR
PHP & JS FRAMEWORK 13
EXAMPLE
PHP & JS FRAMEWORK 15
EXAMPLE
//named function
• function sqr(a)
• {
• return a*a;
• }
• console.log("the invoking named function:" +sqr(2));
• //anonymous function
• var z=function(b)
• {
• return b*b;
• }
• console.log("anonymous function:" +z(2));
• //constructor function
• var q=new Function("v","return v*v;");
• console.log("constructor function:" +q(2));
• (function(d)
• {
• console.log("self invoking function:"+ d*d);
• return d*d;
• })(2);
16