Could you explain me what this class does? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

Could you explain me what this class does?

I read this code somewhere today and I couldn't understand it very well, I don't understand what exactly happens. Why does the method execute immediately after the object is created? Could someone explain what happens behind the scenes in more detail? I know what result it's gonna give, but I don't understand why it works. https://code.sololearn.com/Wa2A197A12A2

27th Jan 2021, 7:25 AM
Karak10
Karak10 - avatar
1 Antwort
+ 1
It seems like I'm not gonna get an answer any time soon, but after I did my own research I believe I probably understood that now, what I didn't understand before was that RegExp,prototype[Symbol.replace]() method is executed when String.prototype.replace() method is used with a regular expression pattern. If anyone wants to know more you can check my notes, they are not perfect however, and some of the stuff I write there can possible be wrong: http://karak10notes.c1.biz/Notes24.html#three
28th Jan 2021, 11:05 AM
Karak10
Karak10 - avatar