Skip to content

Instantly share code, notes, and snippets.

@elijahmanor
Forked from anonymous/confusion.js
Last active December 11, 2015 19:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elijahmanor/4646532 to your computer and use it in GitHub Desktop.
Save elijahmanor/4646532 to your computer and use it in GitHub Desktop.
// The previous code could be rewritten as the following
$( ".widget" ).css( "color", "green" );
// Indications of Confusion
$( ".widget" ).each( function() {
$( this ).css( "color", "green" );
});
// Explicit Loops
$( ".widget" ).each( function( index, element ) {
$( element ).append( index );
});
// Implicit Loops
$( ".widget" ).addClass( "highlight" );
// The previous code could be rewritten as the following
$( ".widget" ).css({
"color": "green",
"font-size": "16px"
});
// Performance Implications
$( ".widget" ).css( "color", "green" ).css( "font-size", "16px" );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment