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
//From http://youtu.be/PMfcsYzj-9M?t=14m48s | |
var AnswerPrototype = { | |
constructor: function fn0(value) { | |
this._val = value; | |
}, | |
get: function fn1() { | |
return this._val; | |
} | |
}; |
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
// Get Numbers From Array | |
Array.prototype.getArrayNumbers = function(){ | |
var _this = this; | |
for(var i = _this.length; i--;){ | |
if ( typeof(_this[i]) !== 'number' ) _this.splice(i, 1); | |
} | |
return _this; | |
}; |
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
// Sort Numerically | |
Array.prototype.sortNumerically = function (direction) { | |
var _this = this; | |
function comparator(a, b) { | |
return direction < 0 ? b - a : a - b; | |
} | |
return _this.sort(comparator); | |
}; |
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
// Get strings From Array | |
Array.prototype.getArrayStrings = function () { | |
var _this = this; | |
for (var i = _this.length; i--;) { | |
if (typeof (_this[i]) !== 'string') _this.splice(i, 1); | |
} | |
return _this; | |
}; |
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
// Sort Alphabetically | |
Array.prototype.sortAlphabetically = function (direction) { | |
var _this = this; | |
function comparator(a, b) { | |
if (direction < 0) { | |
return a == b ? 0 : a < b ? 1 : -1; | |
} else { | |
return a == b ? 0 : a < b ? -1 : 1; | |
} | |
} |
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
// Production steps of ECMA-262, Edition 5, 15.4.4.14 | |
// Reference: http://es5.github.io/#x15.4.4.14 | |
if (!Array.prototype.indexOf) { | |
Array.prototype.indexOf = function(searchElement, fromIndex) { | |
var k; | |
// 1. Let O be the result of calling ToObject passing | |
// the this value as the argument. | |
if (this == 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
function hasLocalStorage() { | |
try { | |
return 'localStorage' in window && window['localStorage'] !== null; | |
} catch (e) { | |
return false; | |
} | |
} |
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.addEventListener("keydown", function (e) { | |
var newKp = 'key' + e.keyCode, | |
keyID, | |
key = { | |
'key38': function () { | |
alert('up'); | |
}, | |
'key40': function () { | |
alert('down'); | |
}, |
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
/** | |
* @author Julien Etienne | |
* Sets the style of an element with the appropriate browser prefix. | |
* @param {Object} styleObject - Style detials. | |
* @param {Object} styleObject.el - The element to apply the style to. | |
* @param {String} styleObject.style - The style that may require a prefix. | |
* @param {String|Number} styleObject.value - The value to be applied. | |
*/ | |
function stylePrefix(styleObject) { | |
var element = styleObject.el, |
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
/** | |
* hasIOS6RequestAnimationFrameBug. | |
* @See {@Link https://gist.github.com/julienetie/86ac394ec41f1271ff0a} - Commentary. | |
* @Copyright 2015 - Julien Etienne. | |
* @License: MIT. | |
*/ | |
function hasIOS6RequestAnimationFrameBug() { | |
var hasMobileDeviceWidth = screen.width <= 768 ? true : false, | |
requiresWebkitRequestAnimationFrame = !((window.webkitRequestAnimationFrame && window.requestAnimationFrame)), | |
hasNoNavigationTiming = window.performance ? false : true; |
OlderNewer