So last I tried to index a prototype object (e.g: String.prototype) using a for...in statement I was able to get all its methods and properties.
But now I seem to be unable to index the prototype as I`ve tried recently.
let stringProto = String.prototype;
for (let i in stringProto)
console.log(i) // code not running, why? :'(
I've checked if the prototype is iterable using Symbol.iterator and it is but it still does not index its properties.
GOAL
I want to be able to index each method/ property of a prototype object in JavaScript (I`m going to back them up in a separate private object).
REASON:
- It's for a JavaScript library I`m working on: https://github.com/LapysDev/LapysJS.
- Useful for preventing edge-cases like this:
String.prototype.replace = nullfrom getting in the way of running your code.