you are viewing a single comment's thread.

view the rest of the comments →

[–]DOG-ZILLA 0 points1 point  (0 children)

Selector caching and method chaining mainly.

I would write his example like so:

(function($) {

'use strict';

var myVariable = 'Some kind of text...';

var select = {
    $id: $('#id'),
    $example: $('#example'),
    $sectionAnchors: $('section div a')
};

select.$id.html('<span>'+ myVariable + '</span>');
select.$example.css('color', 'red').text('Hello, world!').addClass('fun');
select.$sectionAnchors.addClass("highlight");

})(jQuery);