JavaScript Functions / PDF



JavaScript Functions / PDF
JavaScript Functions / PDF







Sample of the PDF document 








A function is a major programming construct that you have not yet seen — but, I’d argue, once you’ve seen it, you might wonder how you ever lived without it :)

• The reality is that you’ve already been using functions
— alert, prompt, parseFloat, parseInt, among others, are actually functions
• What you haven’t done yet is to make your own functions — until now


What is a Function?
• A function is an object that carries out a specific computation (i.e., it represents an algorithm)
• Functions are written (“defined”) once, but can be used or run (“called”) over and over again
• Functions allow you to express an algorithm once, then it as many times as you like without having to copy
its instructions all over the place
• Since they represent algorithms, functions have explicit constructs for working with their input and output


Anatomy of a Function
• As with any other JavaScript construct, a function must be defined using a particular format
• This format is likely more complicated than anything you have seen before; your reward for mastering it is
the ability to define sequences of code that you can use over and over, for the life of a program
Experienced programmers build “libraries” of useful functions, and frequently share them with (or sell them to) others
• To illustrate this format, we have chosen to “annotate” a sample function and an instance of its use.....







Download JavaScript Functions / PDF










JavaScript Functions / PDF



0 commentaires: