将字符串传递给settimeout是不好的做法吗?如果是,为什么?
问题描述:
我刚读了一条评论说这是不好的做法..是这样的吗?为什么?
I just read a comment stating it is bad practice.. Is that so? And why?
答
是的,它是。
字符串必须 eval
'd,是邪恶的(并且非常慢)。
它还会阻止你在回调中使用局部变量。
The string must be eval
'd, which is evil (and very slow).
It also prevents you from using local variables in the callback.