Skip to content

Instantly share code, notes, and snippets.

@lethern
Created February 28, 2019 15:03
Show Gist options
  • Select an option

  • Save lethern/164c8542eac646696eac3d900524d6f3 to your computer and use it in GitHub Desktop.

Select an option

Save lethern/164c8542eac646696eac3d900524d6f3 to your computer and use it in GitHub Desktop.
endsWith = function (str, suffix) {
if (str.length < suffix.length)
return false;
var suff_i = suffix.length - 1;
var str_i = str.length - 1;
for (; suff_i >= 0;) {
if (str.charAt(str_i) != suffix.charAt(suff_i))
return false;
--suff_i;
--str_i;
}
return true;
};
checkGlobalVariables = function () {
var myObjects = [
'UTILS', //...
];
var arr = Object.keys(window);
var arrNew = [];
var arrIDs = [];
for(var i=0; i<arr.length; ++i){
var el = arr[i];
if( myObjects.indexOf(el) >= 0 )
continue;
if (UTILS.endsWith(el, '_id')) {
arrIDs.push(el);
continue;
}
arrNew.push(el);
}
if (arrNew.length>0)
alert( arrNew.join(', ') );
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment