var.replace is not a function

前端 未结 10 2287
悲&欢浪女
悲&欢浪女 2020-12-04 13:50

I\'m using the below code to try to trim the string in Javascript but am getting the error mentioned in the title:

function trim(str) {
    return str.replac         


        
10条回答
  •  Happy的楠姐
    2020-12-04 14:25

    make sure you are passing string to "replace" method. Had same issue and solved it by passing string. You can also make it to string using toString() method.

提交回复
热议问题