This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.localStorage is not null # window.localStorage === !null | |
window.localStorage isnt null # window.localStorage !== null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a fairly common pattern. First, define a constructor... | |
var Person = function(firstName, lastName) { | |
this.firstName = firstName; | |
this.lastName = lastName; | |
}; | |
// ...then define some methods by mixing into the prototype | |
$.extend(Person.prototype, { | |
sayHello: function() { | |
console.log('Hello, I\'m ' + this.getFullName()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var shuffle = function(source) { | |
var ret = Array.prototype.slice.call(source), | |
len = source.length, | |
i = len, | |
rand, temp; | |
while (i--) { | |
rand = parseInt( Math.random() * len, 10 ); | |
temp = ret[ i ]; | |
ret[ i ] = ret[ rand ]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jQuery UI sugar: an easy way to limit a plugin generated by the widget | |
// factory down to the first element. This is useful for widgets like dialog | |
// and mediaplayer that should be instantiated/configured individually. | |
$.widget.singularize = function(widgetName) { | |
// Keep a reference to the auto-generated plugin, so that we can use it later | |
var widget = $.fn[ widgetName ], | |
slice = Array.prototype.slice; | |
// Abort is widget doesn't exist to avoid creating random properties on $.fn | |
if (!widget || !($.isFunction(widget))) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isIDevice = navigator.platform.toLowerCase() in { | |
"ipod": true, | |
"ipad": true, | |
"iphone": true | |
}; |