Presentation is loading. Please wait.

Presentation is loading. Please wait.

Javascript Functions.

Similar presentations


Presentation on theme: "Javascript Functions."— Presentation transcript:

1 Javascript Functions

2 Function Header Line function name arguments
Myfunction ( ) function name arguments Myfunction( ) is called by using Myfunction() on a line * * * * *

3 body { Parts of all Functions Function: header fnname( ) { }
{ } body { note alignment * * *

4 Basics of Functions Shorthand way of accomplishing a single, cohesive task. May be used any number of times. Functions can call other functions. Functions remember where they were called from and return to the next statement upon completion.

5 Example Function function sayHello(name) { alert (“Hello” + name); }
sayHello (“Charles”); * *

6 Functions Passing Parameters Arguments

7 Style for Functions Each function should be preceded by a block comment that includes: author name & date description of the module list of external modules used by this one any citations or other notes Use “whitespace” before and after. Readability counts! *

8 Style Provides Readability
Programmer Friendly consistent spacing predictable placement mnemonic identifiers Typical “large” program in school, 3-5K lines “real-world” projects over 100K lines many are over 1M


Download ppt "Javascript Functions."

Similar presentations


Ads by Google