DEV Community

Discussion on: Most Useful JavaScript functions for Web Developers

Collapse
 
suchintan profile image
SUCHINTAN DAS

Thanks Luke , for sharing the amazing information. There are some stuffs I want to clear -

Regarding use of prototype.call on map and filter function. The reason why I shared it is because people can really understand the beneath concept and most of the time on internet they used to share the proper structure for these function but never used to show the use of that callback arguement.

//value for callback function
const map1 = Array.prototype.map.call(array1,
(x) => 
{return x * 2});
Enter fullscreen mode Exit fullscreen mode
//value for callback function
const updatearray = Array.prototype.filter.call(numbers,
(element) => {return element > 6});
Enter fullscreen mode Exit fullscreen mode

Due to this reason I thought it's important to show the main proper structure. Yes, it's just for your knowledge ! You don't have to use it on workplace , but it would help you build the base of JavaScript which is kinda important.

Hope it's clear now.

Collapse
 
perssondennis profile image
Dennis Persson

I agree that it's important to understand prototypes in js, you should definitely teach about it.

But I think it will just confuse the target audience of this article. Begginer level developers who wants to learn about map and filters have no chance to understand how the prototype works by looking at a one liner example like that.

Thread Thread
 
suchintan profile image
SUCHINTAN DAS

Yes Dennis, I know it may be little bit difficult for the beginners to understand the prototypes in js.

That's the reason I only used the the structure avoiding too much explanation of it. In this way they will have the idea that the prototype structure is a bit complicated and that's why we use the first one on each of them.

It's like I introduced them that there are prototypes in JavaScript but knowing more about it comes as a choice to them.