Please navigate to the bottom of the page for Table of Contents

Sunday, July 29, 2012

JavaScript functions explained

Functions are the basic building blocks in JavaScript. They can be used everywhere, can be passed as parameters, attached as event handlers, overridden, deleted, etc. Functions can be anonymous or not.

// In the example below, dont forget the semicolon!
// However, its name will not appear in the debugger
var anonymous = function() {
console.log('anonymous function!');

// This the classic syntax, without a semicolon at the end!
function nonAnonymous() {
console.log('non anonymous!');

// This is similar to the above, but is more
// debugger-friendly, as the name of the function
// will be printed in the debugger.
var nonAnonymous2 = function nonAnonymous2() {
console.log('non anonymous too!');

// This is the syntax for adding event handlers in jQuery
function(event, data) {
console.log('binding an anonymous function!');


  1. Nice Explained JavaScript functions, Helful me & also given answer 7 question on - Thanks sir

  2. Wonderful blog! I found it while searching on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Many thanks.
    2048 game | five nights at freddy's 4 | five nights at freddy's 3 | fireboy and watergirl | fireboy and watergirl 4||red ball | age of war

  3. This comment has been removed by the author.

  4. This is a great post; it was very edifying. I look ahead in reading more of your work.
    webdesign agencies

  5. Managing the project effectively,web design firm services names team were accessible and receptive to feedback.

  6. The team was impressed with their candid and transparent approach.
    brand service San Francisco

  7. Your blogs are easily accessible and quite enlightening so keep doing the amazing work guys.
    UI consultant

  8. Remarkable blog! I have no words to praise, it has really allured me.
    brand strategy agency

  9. Baltic Legal specializes in corporate law, tax law, company formation and registration and accounting services in all three Baltic countries - Estonia, Latvia and Lithuania.