954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

javascript function

Hi ,can anyone tell me if we pass a function to another function as a parameter in javascript?

annomalis
Newbie Poster
1 post since Jun 2007
Reputation Points: 10
Solved Threads: 0
 

Yes.

<html>
<head>
<script>
    function add(a, b)
    {
        alert(a + b);
    }

    function takingFunction(x, y, func)
    {
        func(x, y);
    }
</script>
<head>
<body>
<form>
    <input type="submit" value="Submit" onclick="javascript:takingFunction(2, 3, add)" />
</form>
</body>
</html>
~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You