Home >Web Front-end >JS Tutorial >A friendly and improved implementation of Object.prototype.toString_javascript skills

A friendly and improved implementation of Object.prototype.toString_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:15:131190browse

JavaScript中几乎每个对象都有一个 toString()方法,而且是内置的.用来输出当前
变量的信息. 但是对于我们最常用的Object对象.每次用 toString都是打印[object Object]
{a:1,b:2,c:3}.toString()  ===> [object Object]
让人十分郁闷,为此我实现了一个友好的,打印Object各成员的函数,
支持嵌套输出 ,也能友好打印数组内容.
这里贴出代码,希望和大家一起学习,一起完善,改进这个函数.
说句题外话,用 Vim写程序,可不是一般的爽啊.
我表达能力有限,只能用 "爱不释手" 来表达我对 Vim 的爱
http://www.vim.org/


[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn