jquery exercises

jQuery: Check the lock-state of a callback list

jQuery Fundamental - II: Exercise-51

Check the lock-state of a callback list.

Sample solution :

HTML Code :

<!DOCTYPE html>
  <script src="https://code.jquery.com/jquery-git.js"></script>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Check  the lock-state of a callback list.</title>

JavaScript Code :

// A sample function f1 
var foo = function( value ) {
  console.log( "foo: " + value );
var callbacks = $.Callbacks();
// Add f1 to the callback list
callbacks.add( foo );
// Fire the items on the list, passing an argument
callbacks.fire( "JavaScript" );
// Lock the callbacks list
// Test the lock-state of the list
console.log ( callbacks.locked() );
// true

See the Pen jquery-fundamental-exercise-51 by w3resource (@w3resource) on CodePen.

Contribute your code and comments through Disqus.

Previous: jQuery Fundamental - II exercises
Next: Remove a single callback or a set of callbacks from a callback list.

What is the difficulty level of this exercise?

New Content: Composer: Dependency manager for PHP, R Programming