Skip to content

Instantly share code, notes, and snippets.

@Dinir
Last active July 26, 2017 02:04
Show Gist options
  • Save Dinir/79cd92169bede28318b95d31d149e33b to your computer and use it in GitHub Desktop.
Save Dinir/79cd92169bede28318b95d31d149e33b to your computer and use it in GitHub Desktop.
IE10 😑
/**
* μ˜€λΈŒμ νŠΈκ°€ λΉ„μ–΄μžˆλŠ”μ§€ ν™•μΈν•©λ‹ˆλ‹€.
*
* @param {object} obj
* @returns {boolean}
*/
var isEmptyObj = function (obj) {
if(obj)
return Object.keys(obj).length === 0 && obj.constructor === Object;
else
return true;
};
/**
* IEμ—μ„œ `Object.values(obj)` λ₯Ό λŒ€μ‹ ν•΄μ„œ μ“Έ 수 μžˆλŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.
*
* @param {object} obj
* @returns {Array}
*/
var objectValues = function (obj) {
var values = Object.keys(obj).map(function (k) {
return obj[k];
});
return values;
};
/**
* @callback forEach~forEachCallback
* @param {!number} index
* @param value
*/
/**
* `[].forEach()` λ₯Ό λŒ€μ‹ ν•΄μ„œ μ“Έ 수 μžˆλŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.
*
* https://toddmotto.com/ditch-the-array-foreach-call-nodelist-hack/#recommendations
*
* @param {!Array.} array
* @param {!forEach~forEachCallback} callback
* @param [scope]
*/
var forEach = function (array, callback, scope) {
for (var i = 0; i < array.length; i++) {
callback.call(scope, i, array[i]);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment