老师,flat函数设计这个,直接调用Array.prototype.toString方法也可以吧,不用重写toString方法吧
来源:7-4 flat函数设计

话不多先生88
2018-02-26
var a = [1,3,4,['1','2'],43,'a',[1,'b'],'c']; console.log(a.toString()); function flat(arr) { Array.prototype.toString = function() { return this.join(',') } return arr + '' } console.log(flat(a))
这两个输出是一样的
写回答
1回答
-
快乐动起来呀
2018-02-26
如果分隔符不是,呢?
322018-02-26
相似问题