Chapter 2 - generics and collection polymorphism 2

by Denise Nepraunig

HTML

<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.14.0.css">
<script src="http://code.jquery.com/qunit/qunit-1.14.0.js"></script>
<ul>
    <li class="friend">Mick</li>
    <li class="friend active">Hunz (active)</li>
    <li class="friend">Yannis</li>
</ul>

JavaScript

// Programming JavaScript Applications
// Chapter 2
// fluent APIs and method chaining

/* jQuery made the method chaining popular and is a good example of a fluent API. But it can also have disadvanteges, imagine to set a break point in the middle of an chained statement. */

// Hide all my friends and then filter the active one and show them
$('.friend').hide().filter('.active').show();