1 / 9

Advanced javascript

Advanced javascript. Functional programming. Concept.

kaycee
Download Presentation

Advanced javascript

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Advanced javascript Functional programming

  2. Concept Functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast with the imperative programming style that emphasizes changes in state.

  3. Concept Higher-order function • take one or more functions as an input • output a function

  4. Anonymous Fuction • var sum = function(x,y,z) • { • return (x+y+z); • }; • sum(1,2,3); function sum(x,y,z) { return (x+y+z); } ; Sum(1,2,3)

  5. Using function as an expression alert (“Hello, World!"); • (alert) (“Hello, World!"); • ( function(x,y,z) { return (x+y+z) } ) (1, 2, 3);

  6. Passing function as a parameter and applying it varpassFunAndApply = function (fn,x,y,z) { return fn(x,y,z); }; varsum = function(x,y,z) { return x+y+z; }; alert( passFunAndApply(sum,3,4,5) ); // 12

  7. functional concepts • Functions need not have names all the time. • Functions can be assigned to variables like other values. • A function expression cqn be written and enclosed in parentheses for application later. • Functions can be passed as arguments to other functions.

  8. Example

  9. Resource http://www.ibm.com/developerworks/java/library/wa-javascript.html

More Related