【发布时间】:2017-02-20 09:35:08
【问题描述】:
为什么我不能这样做:
string.replace(this.slice(0,1), '');
错误日志:
TypeError: this.slice is not a function
【问题讨论】:
-
你想做什么?
-
因为
this指的是它的父上下文(它在里面执行的函数)。 -
@LucasCosta 我要删除第一个字符
-
var str = 'test'; str.replace(str.slice(0,1), '');
标签: javascript string replace this slice