<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vadim Mukabenov on Medium]]></title>
        <description><![CDATA[Stories by Vadim Mukabenov on Medium]]></description>
        <link>https://medium.com/@vadim.mukabenov98?source=rss-4ddde872d5bf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5ZXE4jTNdmjK3-9q5haNBg.jpeg</url>
            <title>Stories by Vadim Mukabenov on Medium</title>
            <link>https://medium.com/@vadim.mukabenov98?source=rss-4ddde872d5bf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 14 Nov 2026 23:02:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vadim.mukabenov98/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to write your own polyfills in JavaScript#4]]></title>
            <link>https://towardsdev.com/how-to-write-your-own-polyfills-in-javascript-4-497c42fa7c1c?source=rss-4ddde872d5bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/497c42fa7c1c</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Vadim Mukabenov]]></dc:creator>
            <pubDate>Thu, 14 Jul 2022 09:22:00 GMT</pubDate>
            <atom:updated>2022-08-24T08:11:53.392Z</atom:updated>
            <content:encoded><![CDATA[<h4>Hi, there! In today’s article we’re gonna implement some methods of Array.prototype!</h4><p>Here they are: <strong>concat, flat</strong>!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U89M-Yd5j4ytmW5DC9nUuQ.png" /></figure><h3>concat</h3><p>According to the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat"><strong>docs</strong></a><strong>:</strong></p><blockquote><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat">The </a><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat">concat() method is used to merge two or more arrays. This method does not change the existing arrays, but instead returns a new array.</a></blockquote><p>for more information see the docs:</p><p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat">Array.prototype.concat() - JavaScript | MDN</a></p><p>Before jumping into code I encourage you to stop and think how you would solve this task. How would you write <strong>concat </strong>method?</p><p>To do that, you can write some <a href="https://en.wikipedia.org/wiki/Pseudocode">pseudo code</a> before any task.</p><p>Let’s get started!</p><pre>This is pseudo code</pre><pre>//  define newArray as copy of baseArray</pre><pre>//  iterate over args</pre><pre>//  if arg is an array</pre><pre>//      iterate over arg</pre><pre>//      push arg[el] into newArray</pre><pre>//  else</pre><pre>//      push arg into newArray</pre><pre>//  return newArray</pre><pre>//  baseArr is an array we concat &#39;args&#39; to</pre><pre>//  ...args is an array of all arguments passed into concat</pre><pre>function concat(baseArr, ...args) {</pre><pre>    const newArray = baseArr;</pre><pre>    for(let arg of args) {</pre><pre>        if(Array.isArray(arg)){</pre><pre>            arg.forEach(el =&gt; newArray.push(el));</pre><pre>        } else {</pre><pre>            newArray.push(arg);</pre><pre>        }</pre><pre>     }</pre><pre>     <br>     return newArray;</pre><pre>}</pre><pre>console.log(concat([1, 2, 3, 4], [5, 6, 7, 8]));</pre><pre>// Output<br>// [1, 2, 3, 4, 5, 6, 7, 8]</pre><p>Ok, we got this! It’s not hard, right?</p><p>Now let’s move to flat!</p><h3>flat</h3><p>According to the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat"><strong>docs</strong></a><strong>:</strong></p><blockquote><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat">The </a><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat">flat() method creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.</a></blockquote><p>for more information see the docs:</p><p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat">Array.prototype.flat() - JavaScript | MDN</a></p><p>I won’t implement <strong>depth </strong>parameter but you can try it yourself!</p><p>Checkout this <a href="https://www.youtube.com/watch?v=2ZH_1d8TYVg&amp;ab_channel=PJCHENder"><strong>video</strong></a><strong> </strong>about<strong> callstack.</strong></p><blockquote>Hint: <strong>depth </strong>is height of callstack</blockquote><p>Let’s dive into code</p><pre>Pseudo code</pre><pre>//  1)  define flattened array</pre><pre>//  2)  iterate over arr</pre><pre>//  3)  if element is an array</pre><pre>//  4)      go back to step 2)</pre><pre>//  5)  else</pre><pre>//  6)      push element into flattened</pre><pre>//  7)  return flattened<br></pre><pre>function flat(baseArr) {</pre><pre>      const flattened = [];</pre><pre>      function flatFn(arr) {</pre><pre>          for(let element of arr) {</pre><pre>              if(Array.isArray(element)) {</pre><pre>                    flatFn(element);</pre><pre>              } else {</pre><pre>                    flattened.push(element);</pre><pre>              }</pre><pre>          }</pre><pre>       }</pre><pre>       flatFn(baseArr);<br></pre><pre>       return flattened;</pre><pre>}</pre><pre>const arr = [0, 1, 2, [[[3, 4]]]];</pre><pre>console.log(flat(arr));</pre><pre>// Output </pre><pre>// [0, 1, 2, [3, 4]]</pre><p>That’s it for today! Thank you for reading! Don’t forget to give a feedback if something is not clear!</p><p><strong>See ya!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=497c42fa7c1c" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/how-to-write-your-own-polyfills-in-javascript-4-497c42fa7c1c">How to write your own polyfills in JavaScript#4</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to write your own polyfills in JavaScript#3]]></title>
            <link>https://medium.com/@vadim.mukabenov98/how-to-write-your-own-polyfills-in-javascript-3-860bd54bb6ce?source=rss-4ddde872d5bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/860bd54bb6ce</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Vadim Mukabenov]]></dc:creator>
            <pubDate>Sat, 09 Jul 2022 13:34:47 GMT</pubDate>
            <atom:updated>2022-07-09T13:34:47.934Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey, how’s it going? Today we’re gonna talk about <strong>replace </strong>method of String.prototype!</p><h3>replace</h3><p>According to the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach"><strong>docs</strong></a><strong>:</strong></p><blockquote><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace">The </a><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace">replace() method returns a new string with some or all matches of a </a><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace">pattern replaced by a </a><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace">replacement.</a></blockquote><p>for more information see the docs:</p><p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace">String.prototype.replace() - JavaScript | MDN</a></p><p>I won’t make a function that supports RegExp. You can try to do it on you own and share the results in the comments section.</p><p>Let’s dive into the code!</p><pre>function replace(str, substr, newSubstr) {</pre><pre>    //  first index of &#39;substr&#39; in &#39;str&#39;</pre><pre>    let firstIndexOfSubstr = str.indexOf(substr); // 0<br></pre><pre>    //  index of the rest of the &#39;str&#39; after &#39;substr&#39;</pre><pre>    let indexOfTheRest = firstIndexOfSubstr + substr.length; // 4</pre><pre>    <br>    //  string before &#39;substr&#39;</pre><pre>    let strBefore = str.slice(0, firstIndexOfSubstr);</pre><pre>    <br>    //  string after &#39;substr&#39;</pre><pre>    let strAfter = str.slice(indexOfTheRest);</pre><pre><br>    //  returns new string</pre><pre>    return strBefore + newSubstr + strAfter;</pre><pre>}</pre><pre>let email = &#39;mr_john@mail.com&#39;;</pre><pre>let replacedEmail = replace(email, &#39;john&#39;, &#39;Vadim&#39;);</pre><pre>console.log(replacedEmail);</pre><pre>//  Output</pre><pre>//  <a href="/service/mailto:mr_Vadim@email.com">mr_Vadim@mail.com</a><br></pre><p>Great! Now you know how you could create a String.prototype.replace polyfill for yourself.</p><p>In reality, it’s better not to write you own polyfills for <strong>production code, because it might create bugs. </strong>But it’s a great thing to do for your<strong> learning and development code.</strong></p><h4>See ya!</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=860bd54bb6ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to write your own polyfills in JavaScript#2]]></title>
            <link>https://medium.com/@vadim.mukabenov98/how-to-write-your-own-polyfills-in-javascript-2-bd40f431a31b?source=rss-4ddde872d5bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd40f431a31b</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[writing]]></category>
            <dc:creator><![CDATA[Vadim Mukabenov]]></dc:creator>
            <pubDate>Fri, 08 Jul 2022 04:57:01 GMT</pubDate>
            <atom:updated>2022-07-09T10:38:50.539Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey, in today’s article we’re going to talk about <strong>forEach</strong>, <strong>map</strong>, <strong>reduce</strong>, <strong>filter</strong>!</p><h3>forEach</h3><p>According to the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach"><strong>docs</strong></a><strong>:</strong></p><blockquote><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach"><strong>the forEach </strong>method<strong> </strong>executes a provided function once for each array element.</a></blockquote><p>for more information see the docs:</p><p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach">Array.prototype.forEach() - JavaScript | MDN</a></p><blockquote>It iterates over each element of an array.</blockquote><p>Sounds familiar, isn’t it?</p><p>Of course! That’s what a <strong>for loop</strong> does!</p><pre>const array = [1, 2, 3, 4];</pre><pre>for(let i = 0; i &lt; array.length; i++) {</pre><pre>    console.log(array[i]);</pre><pre>}</pre><p>Under the hood, I believe, the <strong>forEach</strong> does something similar to the example above.</p><p>Remember that <strong>forEach</strong> accepts a <strong>callback function</strong> that is invoked with every element of a <strong>provided array</strong>?</p><p>Look at the for loop again, how do you think what can we do to invok a callback function and pass it every element of the array?</p><p>If you said, wrap it in a function, you’re right!</p><p>Let’s dive into the code:</p><pre>// we moved array out of the forEach function</pre><pre>// now we pass it as an argument</pre><pre>const array = [1, 2, 3, 4];</pre><pre>function forEach(array, callback) {</pre><pre>   for(let i = 0; i &lt; array.length; i++) {</pre><pre>       callback(array[i], i, array);</pre><pre>   }</pre><pre>}</pre><pre>forEach(array, console.log);</pre><pre>// output<br>// 1<br>// 2<br>// 3<br>// 4</pre><p>Wow, now our code looks a lot more flexible! We can pass it whatever callback functions we like, and it’ll work!</p><h3>map</h3><blockquote><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map">The </a><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map"><strong>map()</strong> method creates a new array populated with the results of calling a provided function on every element in the calling array.</a></blockquote><p>for more information see the docs:</p><p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map">Array.prototype.map() - JavaScript | MDN</a></p><p>Sounds almost the same as <strong>forEach</strong>, isn’t?</p><p>Again, you’re right! Let’s take a look at the implementation!</p><pre>function map(array, callback) {<br>        <br>     // step #1. Define a new empty array</pre><pre>     let newArray = [];</pre><pre>     // step #2. Iterate over &#39;array&#39; and push return value<br>     // of &#39;callback&#39; to &#39;newArray&#39;</pre><pre>     for(let i = 0; i &lt; array.length; i++) {</pre><pre>         newArray.push(callback(array[i], i, array));</pre><pre>     }</pre><pre>     // step #3. Return the &#39;newArray&#39;</pre><pre>     return newArray;</pre><pre>}</pre><pre>const array = [1, 2, 3, 4];</pre><pre>// es6</pre><pre>console.log(map(array, el =&gt; el * 2));</pre><pre>// es5</pre><pre>console.log(map(array, function(el) {</pre><pre>     return el * 2</pre><pre>}));</pre><pre>// Output:<br>// 2<br>// 4<br>// 6<br>// 8</pre><p>See? It looks very similar to <strong>forEach</strong>, the difference is just we create a new empty array and pass it return values of the <strong>‘callback’</strong> function. That’s it!</p><h3><strong>reduce</strong></h3><blockquote><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce">Perhaps the easiest-to-understand case for </a><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce">reduce() is to return the sum of all the elements in an array.</a></blockquote><p>for more information see the docs:</p><p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce">Array.prototype.reduce() - JavaScript | MDN</a></p><p>Oh boy, that’s a tricky one!</p><p>To understand <strong>reduce</strong>, we’ll take an array and sum all it’s elements.</p><pre>// how would you sum all the elements?<br>// probably iterate over the array and add every value to a store<br>// like this:<br>// store = 1<br>// store = 1 + 2 = 3<br>// store = 3 + 3 = 6<br>// store = 6 + 4 = 10<br>// store = 10<br>// we did it!</pre><pre>const array = [1, 2, 3, 4];<br></pre><pre>function reduce(array, callback, initialValue) {<br>    // step #1. Create our &#39;store&#39;</pre><pre>    let store = initialValue || 0;</pre><pre>    // step #2. Iterate over &#39;array&#39; and save return value<br>    // of &#39;callback&#39; to &#39;store&#39;</pre><pre>    for(let i = 0; i &lt; array.length; i++) {</pre><pre>        store = callback(store, array[i]);</pre><pre>    }</pre><pre>    <br>    // step #3. Return the &#39;store&#39;</pre><pre>    return store;</pre><pre>}</pre><pre>// es6<br>// &#39;prev&#39; means previous element of the array<br>// &#39;next&#39; means next element of the array</pre><pre>console.log(reduce(array, (prev, next) =&gt; prev + next, 0));</pre><pre>// Output:<br>// 10</pre><p>We did it! We found the sum of the array!</p><p>I hope it’s now clearer to you how <strong>reduce </strong>works under the hood.</p><h3><strong>filter</strong></h3><blockquote><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter">The </a><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter">filter() method creates a shallow copy of a portion of a given array, filtered down to just the elements from the given array that pass the test implemented by the provided function.</a></blockquote><p>for more information see the docs:</p><p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter">Array.prototype.filter() - JavaScript | MDN</a></p><p>Last but not least, <strong>filter</strong>!</p><p>It works like <strong>map</strong>, but instead of modified copy of an array it filters out all elements that don’t match the condition.</p><p>Let’s dive into code!</p><pre>const array = [1, 2, 3, 4];<br></pre><pre>function filter(array, callback) {<br>    // step #1. same as in map</pre><pre>    let newArray = [];<br></pre><pre>    // step #2. same as in map</pre><pre>    for(let i = 0; i &lt; array.length; i++) {</pre><pre>        // difference between map and filter<br>        // before pushing to &#39;newArray&#39; we make sure<br>        // that &#39;callback&#39; returned &#39;true&#39;</pre><pre>        if(callback(array[i], i, array)) {</pre><pre>            newArray.push(array[i]);</pre><pre>        }</pre><pre>    }</pre><pre>    <br>    // step #2. same as in map</pre><pre>    return newArray;</pre><pre>}</pre><pre>// es6</pre><pre>console.log(filter(array, el =&gt; el &gt; 2));</pre><pre><br>// Output:<br>// [3, 4]</pre><p>That’s it for today! These methods are very similar and very useful!</p><p>I hope you understand them better now! If there’s something you want to tell me, hit me up at the comments section below!</p><p>See ya!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd40f431a31b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to write your own polyfills in JavaScript#1]]></title>
            <link>https://medium.com/@vadim.mukabenov98/how-to-write-your-own-polyfills-in-javascript-1-ebc0705dcdcb?source=rss-4ddde872d5bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/ebc0705dcdcb</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Vadim Mukabenov]]></dc:creator>
            <pubDate>Tue, 28 Jun 2022 20:02:21 GMT</pubDate>
            <atom:updated>2022-07-02T18:54:40.945Z</atom:updated>
            <content:encoded><![CDATA[<p>Today, I wanna show you how to write your own polyfills in JavaScript, so you can learn a bit more about how JavaScript internal functions work. If you think I made a mistake, please do not hesitate to reach out to me in the comment section or in DM.</p><p>In today’s article we’ll cover <strong>3</strong> popular function of <strong>Function.prototype</strong>:</p><h4><strong>Call, Apply and Bind!</strong></h4><p>Before, we dive in to code we need to add some definitions:</p><p><strong>this:</strong> it is a keyword that refers to an object. Which object it refers to depends on where it’s used: in a method or in a function.</p><p>First of all, we’ll start with <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call"><strong>call</strong> </a>function.</p><h3>Call</h3><blockquote><strong>Call</strong> function lets you invoke a function or a method with specific ‘<strong>this</strong>’.</blockquote><p><strong>func</strong>: it is a function being invoked by <strong>‘call’</strong> method.</p><p><strong>thisArg</strong>: it refers to <strong>‘this’</strong> when you call <strong>‘func’.</strong></p><p><strong>arg1, arg2, …argN</strong>: arguments for the <strong>‘func’.</strong></p><h4>Implementation:</h4><pre>function call(func, thisArg, ...args) {</pre><pre>//  1. add &#39;func&#39; to &#39;thisArg&#39;</pre><pre>    thisArg[&#39;func&#39;] = func;<br></pre><pre>//  2. call it with &#39;args&#39; and save to &#39;result&#39;</pre><pre>//  when we call thisArg.func(...args) we set &#39;this&#39;<br>//  inside &#39;func&#39; to &#39;thisArg&#39;<br>//       i.e <br>//  this === thisArg</pre><pre>    const result = thisArg.func(...args);<br></pre><pre>//  3. remove &#39;func&#39; from &#39;thisArg&#39;</pre><pre>    delete thisArg[&#39;func&#39;];<br></pre><pre>//  4. return &#39;result&#39;<br>  <br>    return result;</pre><pre>}</pre><pre>const obj = {</pre><pre>   name: &#39;John&#39;</pre><pre>}</pre><pre>function sayName(...args) {<br>     //  this === obj<br>     //  this.name === obj.name</pre><pre>     console.log(<em>this</em>.name, ...args);</pre><pre>}</pre><pre>call(sayName, obj, &#39;Mike&#39;, &#39;Laura&#39;); // John Mike Laura</pre><p>In a function,<strong> ‘this’</strong> refers to a global object. In a <strong>browser</strong> it is <strong>‘window’</strong> object, in <strong>Node.js</strong> it is <strong>‘global’ </strong>object.</p><p>Keep in mind that in <strong>‘strict mode’</strong> in a function <strong>‘this’</strong> refers to <strong>undefined</strong>.</p><h3>Apply</h3><p><strong>‘apply’</strong> method is almost the same as <strong>‘call’</strong> but instead of taking <strong>‘args’</strong> separately, <strong>‘apply’</strong> takes them as an array.</p><h4>Implementation:</h4><pre>function apply(func, thisArg, args) {</pre><pre>  // Note: &#39;args&#39; is an array now</pre><pre>  thisArg[&#39;func&#39;] = func;</pre><pre>  const result = thisArg.func(...args);</pre><pre>  delete thisArg[&#39;func&#39;];<br>  <br>  return result;</pre><pre>}</pre><pre>const obj = {</pre><pre>name: &#39;John&#39;</pre><pre>}</pre><pre>function sayName(...args) {</pre><pre>    console.log(<em>this</em>.name, ...args);</pre><pre>}</pre><pre>apply(sayName, obj, &#39;Mike&#39;, &#39;Laura&#39;); // John Mike Laura</pre><h3>Bind</h3><p><strong>‘bind’</strong> method is pretty similar to <strong>‘apply’</strong> and <strong>‘call’</strong> methods. But instead of returning the result of the invoked function, it returns an anonymous function, that is bound to <strong>‘thisArg’. </strong>In other words, it wraps the logic of ‘call’ or ‘apply’ methods into a wrapper function. And all you have to do is to call this new function whenever you need.</p><pre>function bind(func, thisArg, args) {</pre><pre>  return function(){</pre><pre>    thisArg[&#39;func&#39;] = func;</pre><pre>    const result = thisArg.func(...args);</pre><pre>    delete thisArg[&#39;func&#39;];</pre><pre>    return result;</pre><pre>  }</pre><pre>}</pre><pre>function sayName(...args) {</pre><pre>     console.log(<em>this</em>.name, ...args);</pre><pre>}</pre><pre>const newFuncFromBind = bind(sayName, obj, &#39;Mike&#39;, &#39;Laura&#39;);<br>newFuncFromBind(); // John Mike Laura</pre><p>That’s it for today! If you have any questions or remarks, write them in the comments section below!</p><p>See ya!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ebc0705dcdcb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>