JavaScript function , definition , caller
<!DOCTYPE html>
<!-- 07.27-09.07 -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fuction</title>
</head>
<body>
<button onclick="display()">click me</button>
<p id="demo"></p>
<script>
// function definition
function display(){
// document.write("this is function definition");
document.getElementById("demo").innerHTML = 'Hello world';
}
function display1(){
document.write("this is function definition<br>");
}
display1(); // automatic calling
display1(); // automatic calling
function sum(a,b){
var x = 4; // local variable
c = a+b+x;
return c + '<br>';
}
// document.write(x); // through an error
x = sum(3,5);
document.write(x);
x = sum(3,7);
document.write(x);
x = sum(13,5);
document.write(x);
function program(){
return 'Hello programmers';
}
document.write(program());
</script>
</body>
</html>
No comments:
Post a Comment