当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 一个友好的.改善的 Object.prototype.toString的实现

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 一个友好的.改善的 Object.prototype.toString的实现


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 115 ::
收藏到网摘: n/a

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