Inside attributes like onclick As a section of code in the body Only special cases As a function in a separate file Can link to it like the css We will use
Collection of statements that can be invoked as a unit Can take parameters Can be used multiple times Can call without knowing what they do or how
function name() { stmt; }
Myscript.js JavaScript option in komodo note that it’s an empty file but it can help you do NOT include the script tag
function name(parm) { stmt; }
Name is a placeholder Can be used anywhere in a function Can be used as many times as you want Can not change it MUST supply value when call Can be different everytime
HTMLJS mypet(‘cow’); mypet(‘dog’); function mypet(pet) { alert(‘my pet: ‘+pet); }
Order matters Need different names
HTMLJS mypet(‘Mutt’,’Jeff’); mypet(‘Jeff’,’Mutt’); function taller(big,small) { alert (big+’ is taller than ‘+ small); }
Jsbin is just like jsfiddle but it allows you to see the console Console.log( message );