Last active
March 11, 2019 11:09
Revisions
-
piecioshka renamed this gist
Mar 11, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
piecioshka revised this gist
Mar 11, 2019 . No changes.There are no files selected for viewing
-
piecioshka revised this gist
Jul 16, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -26,7 +26,7 @@ var isArray = Array.isArray || function(o) { */ var isEmptyObject = function (o) { if (!isObject(o) || isArray(o)) return false; return Object.keys ? !Object.keys(o).length : (function (o) { for (var k in o) if (o.hasOwnProperty(k)) return false; return true; })(o) -
piecioshka renamed this gist
Jul 16, 2013 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -26,8 +26,10 @@ var isArray = Array.isArray || function(o) { */ var isEmptyObject = function (o) { if (!isObject(o) || isArray(o)) return false; return Object.keys ? Object.keys(o).length === 0 : (function (o) { for (var k in o) if (o.hasOwnProperty(k)) return false; return true; })(o) }; -
piecioshka created this gist
Jul 16, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ /** * TEST DATA */ var testData = [{}, {a:1}, new RegExp(), [], Object.create(null), [undefined]]; /** * Check if param is Object? * @param {*} o Checks value. * @return {boolean} */ var isObject = function(o) { return o === Object(o); }; /** * Check if param is Array? * @param {*} o Checks value. * @return {boolean} */ var isArray = Array.isArray || function(o) { return ({}).toString.call(o) == '[object Array]'; }; /** * Check if param is EmptyObject? * @param {*} o Checks value. * @return {boolean} */ var isEmptyObject = function (o) { if (!isObject(o) || isArray(o)) return false; for (var k in o) if (o.hasOwnProperty(k)) return false; return true; }; /** * RUN TESTS */ testData.forEach(function (item) { console.log(isEmptyObject(item)); });