Set String via String.prototype function without return

前端 未结 1 1595
孤城傲影
孤城傲影 2020-12-12 04:56

I have the following function to add splice to a string:

String.prototype.splice = function(index, howManyToDelete, stringToInsert) {
    var ch         


        
相关标签:
1条回答
  • 2020-12-12 05:03

    You can't do that. You can't change the value of a string in the way that you change the content of an array.

    Look at the other string methods, and how they return the new string value rather than changing the string in place.

    0 讨论(0)
提交回复
热议问题