IT350_set9_JavaScriptFunctions
IT350_set9_JavaScriptFunctions
Fall 2007
SlideSet #9: JavaScript Functions
• Built-in functions
• User-defined functions
g = 7;
h = 5;
Output?
JavaScript Scope Rules
function fun2 () {
var y;
x = x + 10;
y = y + 20;
document.writeln("<br/> FUN2: "+x+ "," +y);
}
x = 1;
y = 2;
function average(x, y, z) {
return (x + y + z) / 3;
}
– In a separate file
<script type = “text/javascript” src = “calc.js” />
• Quoting
document.writeln("<a href=\"cat.html\">cat</a>");
vs.
document.writeln("<a href='cat.html'>cat</a>");
document.writeln("<h1>",heading,"</h1>");