是什么导致了这个toString方法的不同
What causes the difference in this toString method?
我主要对Object.prototype.toString方法感兴趣。两者都对数组进行操作,但是Object.prototype.toString对输出做了一些不同的事情。为什么会这样?
输出:1、2、3
console.log([1,2,3].toString());
输出:空白
console.log([].toString());
输出:[object Array]
return Object.prototype.toString.apply([]);
因为Array.prototype.toString
与Object.prototype.toString
是不同的函数。
函数的设计者决定让Array stringification输出数组中的数据。
相关文章:
- toBoolean方法类似于toString
- 将toString方法暴露给nashorn中的js对象
- 为什么控制台没有't使用输入的对象's的`toString`方法
- MongoDB原生:toString和toHexString方法之间有什么区别吗?
- JavaScript:Date 的 toString() 和 toLocaleString() 方法之间的区别
- 方法toString是未定义的JavaScript
- 对象的 toString 方法从哪里获取其值
- Ember数据FixtureAdapter hasmany-无法调用方法'toString'的未定义
- console.log是否调用对象的toString方法
- toString 方法打印数组而不是字符串
- 为什么javascript在toString方法中用0代替数字
- 在字符串上使用toString方法是否有任何使用值
- 将日期对象打印为对象,而不是覆盖的tostring方法
- 无法调用方法'toString'ofundefined|我的代码有问题
- 如何在C#中将浮点数转换为Base36,方法与JavaScript's.toString(36)做到了
- 是什么导致了这个toString方法的不同
- 二叉树的toString方法
- 在javascript中访问方法skillet.toString()
- toString()和valueOf()方法的应用领域
- 未捕获类型错误:不能调用方法'toString'零