Book Image

Web Developer's Reference Guide

By : Joshua Johanan, Talha Khan, Ricardo Zea
Book Image

Web Developer's Reference Guide

By: Joshua Johanan, Talha Khan, Ricardo Zea

Overview of this book

This comprehensive reference guide takes you through each topic in web development and highlights the most popular and important elements of each area. Starting with HTML, you will learn key elements and attributes and how they relate to each other. Next, you will explore CSS pseudo-classes and pseudo-elements, followed by CSS properties and functions. This will introduce you to many powerful and new selectors. You will then move on to JavaScript. This section will not just introduce functions, but will provide you with an entire reference for the language and paradigms. You will discover more about three of the most popular frameworks today—Bootstrap, which builds on CSS, jQuery which builds on JavaScript, and AngularJS, which also builds on JavaScript. Finally, you will take a walk-through Node.js, which is a server-side framework that allows you to write programs in JavaScript.
Table of Contents (22 chapters)
Web Developer's Reference Guide
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
9
JavaScript Expressions, Operators, Statements, and Arrays
Index

Callback


Multiple lines of statements are queued rather than being executed simultaneously. A callback function queues the statements and executes them one by one.

Its syntax is as follows:

var callbacks = $.Callbacks();

The object created can be used to add, remove, instantiate, and disable callbacks. The supported functions are callbacks.add(), callbacks.remove(), callbacks.fire(), and callbacks.disable().

callbacks.add()

This function is used to add all the functions in an array that are to be called later.

Parameters

This takes flags as strings as its parameters.

Returns

This method returns the callback's object to which it is associated with, (this).

Description

The callbacks.add() function adds the function to the callback array.

Here is an example of its usage.

Required jQuery Code:

function myFunc1( value ) {
  console.myLog( value );
}

function myFunc2( value ) {
  console.myLog( "myFunc2 says: " + value );
  return false;
}

var callbacks = $.Callbacks();
callbacks.add( myFunc1 );

// Outputs...