Menu

Post image 1
Post image 2
1 / 2
0

String Polyfills and Common Interview Methods in JavaScript

DEV Community·Abhishek sahni·about 1 month ago
#Joz31NM8
Reading 0:00
15s threshold

Introduction In this blog, you are going to learn how JavaScript built-in methods work internally. You will also learn how developers make JavaScript compatible with older browsers using polyfills. What are polyfills : A polyfill is a piece of JavaScript code that adds support for modern features in older browsers that don’t support them natively. If the browser doesn’t have a feature, we create it ourselves. Example : Let's take an example that older browser doesn't support Array.prototype.includes. We write polyfill like this if (!Array.prototype.includes) { Array.prototype.includes = function (value) { for (let i = 0; i < this.length; i++) { if (this[i] === value) { return true; } } return false; }; } What are Built-in methods? Built-in methods are predefined functions provided by the JavaScript runtime environment that are used to perform specific tasks. We don’t need to write the logic from scratch. Conceptually, they are methods (functions) attached to the prototype of built-in objects.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More