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>
<html>
<head>
<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>
</head>
<body>
</body>
</html>
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
callbacks.lock();
// 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?
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/jquery-exercises/2/jquery-fundamental-exercise-51.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics