I was debugging my javascript code in the chrome console the other day and suddenly started hitting a breakpoint in some code I don't recognize. Is it possible that it is a part of the console itself and by accident there was a breakpoint created?
The thing is that this breakpoint was being hit over and over even when I was just typing in the console on a blank page with no scripts running.
Here is the code as it looks in the debugger:
(function i(t){let e;e="string"===t?new String(""):"number"===t?new Number(0):"bigint"===t?Object(BigInt(0)):"boolean"===t?new Boolean(!1):this;const s=[];try{for(let i=e;i;i=Object.getPrototypeOf(i)){if(("array"===t||"typedarray"===t)&&i===e&&i.length>9999)continue;const n={items:[],title:void 0,__proto__:null};try{"object"==typeof i&&Object.prototype.hasOwnProperty.call(i,"constructor")&&i.constructor&&i.constructor.name&&(n.title=i.constructor.name)}catch(t){}s[s.length]=n;const o=Object.getOwnPropertyNames(i),r=Array.isArray(i);for(let t=0;t<o.length&&n.items.length<1e4;++t)r&&/^[0-9]/.test(o[t])||(n.items[n.items.length]=o[t])}}catch(t){}return s})
It looks like it's doing some type checking and returning some primitives, but it is pretty weird. Anyone got any idea what's going on?
I went through the code with the step icon in the debugger and apparently, the variable o used in the loop in the end of the code was the list of like +- 1000 JS registered names (like "String", "Promise", "URLSearchParams", "TouchList", "DeviceMotionEventAcceleration", ...). Perhaps this is a part of the autocomplete tool in the console?