5.02.2016

function in javascript


Function  in javascript
Function is nothing it  just  group the code of javascript, control structure, method calls, operation etc.
Function can be called on required, access it and run it. Thus, it reduce the redundancy of code in same script.
A function can be defined anywhere in the code. Javascript provide the several ways of defining them.
  • function declaration
  • function expression
  • function call
 Now let see example;;
<!DOCTYPE html>
<html>
<body>

<p>here this example calls a function , and returns the
result:</p>

<p id="devg"></p>

<script>
function myFunction(m, n) {
    return m* n;
}
document.getElementById("devg").innerHTML =
myFunction(1,23 );
</script>

</body>
</html>

This is the simplest example, follow  up for more info.
Stay happy with www.howiset.blogspot.com

No comments:

Post a Comment