Is there any way to detect all user defined window properties and variables (global variable) in JavaScript? <<> You will need to work for yourself, read in all the qualities, you can do at the first possible time. . From that point on, you can compare the property list with your static list. So, now we may be like and later Of course, the warning is here, that you can only "freeze" global property list At that time, where your script is able to call it as soon as possible. console.log (window) tried but the list is endless.
var globalProps = []; Read GlobalPopes () {globalProps = object .getOwnPropertyNames (window); } Function findNewEntries () {var current PropList = Object.getOwnPropertyNames (window); Return currentPropList.filter (search duplicate); Function Search Duplicate (Proponym) {Return global page. Index (Propaneme) === -1; }}
// init readGlobalProps (); // Store the current property on the global object
window.foobar = 42; FindNewEntries (); // gives an array of new properties, in this case ['FOOBAR']
No comments:
Post a Comment