Recovering built-in methods that have been overwritten

var iframe = document.createElement(“iframe”); document.documentElement.appendChild(iframe); var _window = iframe.contentWindow; String.prototype.split = _window.String.prototype.split; document.documentElement.removeChild(iframe); Use iframes to recover methods from host objects. Note there are traps with this method. “foo”.split(“”) instanceof Array // false “foo”.split(“”) instanceof _window.Array // true The best way to fix this is to not use instanceof, ever. Also note that var _split … Read more

What is the relationship between event loop and Promise [duplicate]

Each event loop has a microtask queue and a macrotask queue. A microtask is a task that is originally to be queued on the microtask queue rather than a task queue. Refer to https://www.w3.org/TR/html51/webappapis.html#microtask-queue. There are two kinds of microtasks: solitary callback microtasks, such as Promiseļ¼Œ and compound microtasks, such as Object.observe, MutationObserver and process.nextTick … Read more

“const correctness” in C#

I’ve come across this issue a lot of times too and ended up using interfaces. I think it’s important to drop the idea that C# is any form, or even an evolution of C++. They’re two different languages that share almost the same syntax. I usually express ‘const correctness’ in C# by defining a read-only … Read more

Calling base class overridden function from base class method

Unfortunately, no As i’m sure you’re aware, but I’ll state explicitly for completeness – there are only the 2 keywords to control the method invocation: this – this.method() – looks for method starting from the invoking instance’s class (the instance’s “top” virtual table – implied default) super – super.method() – looks for method starting from … Read more