13 Dec 2013, 21:48
Generic-user-small

tom s (2 posts)

There are a numbers of examples in the book where you use this form:

var legislating = new $.Deferred();

Others just use the form:

var legislating = $.Deferred();

Can you explain the difference?

13 Dec 2013, 21:58
Generic-user-small

tom s (2 posts)

I found this in the jquery docs:

The jQuery.Deferred() constructor creates a new Deferred object. The new operator is optional.

This is the kind of thing that peeves me about javascript. There are times when subtle distinctions are totally crucial and times like this when an inconsistency that seems really important is actually meaningless.

Or is there actually a reason to do it one way rather than the other? Based on the docs it seems the use of new is redundant.

  You must be logged in to comment