Is it possible to work with String.prototype?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
9 views
Good afternoon.

Let's say I want the function fn () that can be applied like this:
console.log('Hello'.fn()) //HelloolleH

Never occurred anything better than:
String.prototype.fn = function() { return this + this.split(").reverse().join("); }


Question: is this the right way to deal with String.prototype, and if not, how such to implement?
by | 9 views

2 Answers

0 like 0 dislike
Tip for the future, don't touch never the prototypes of String, Array of it.d. If you must, then it is better to create a class, but in the original prototypes do not go better.
by
0 like 0 dislike
Question from the category of "can I ride clinging to the back of the tram"
2LrtKU.png

Do the laws of physics do not forbid you this. But it is inconvenient, unsafe, and the police will swear.

And with the modification of the original prototypes, all technically it can be done, but it's not a good idea for everyday use.
by

Related questions

0 like 0 dislike
4 answers
0 like 0 dislike
1 answer
0 like 0 dislike
3 answers
asked Apr 9, 2019 by Resident234
110,608 questions
257,186 answers
0 comments
36,596 users