DEV Community

Discussion on: Do we even need if/else?

 
pengeszikra profile image
Peter Vivo

That is the reason to know more about .map .filter .find and .reduce functionality in js. After basic one like if/else, for, while, switch. These functionality is lead to functional programming direction.

Any way

String.prototype.hash =
Enter fullscreen mode Exit fullscreen mode

means you declare one global dependency on your code. I think much better to forget this type of work. Because this declaration influence your team whole application.

Thread Thread
 
joelbonetr profile image
JoelBonetR 🥇

It will be available just when you import the file containing it, not less not more. It just depends on the project architecture. The only concern about setting string (or other data structure) methods like this is the possibility of ES adding a method with the same name and thus having to refactor it everywhere it's used (or deleting it if it's provided along the language)