当前位置: 首页 > 图文教程 > 网络编程 > Javascript > Javascript中的var_dump函数实现代码

Javascript
Javascript array类 数组操作方法
JavaScript 权威指南(第四版) 读书笔记
JQuery jsonp 使用示例代码
JavaScript 十六进制RGB色码转换器
一些不错的JS 自定义函数
javascript 不停(setInterval)/延时(setTimeout)函数使用实例
JS 添加删除元素的实现代码
jQuery 判断页面元素是否存在的代码
css+js完美控制图片大小
获取 textarea 标签第n行的文字的js代码
JavaScript 提升运行速度之循环篇 译文
js中的window.open返回object的错误的解决方法
javascript 客户端验证上传图片的大小(兼容IE和火狐)
用JavaScript将从数据库中读取出来的日期型格式化为想要的类型。
javascript addBookmark 加入收藏 多浏览器兼容
javascript 无提示关闭窗口脚本
jQuery select控制插件
jquery 入门教程 [翻译] 推荐
调用js时ie6和ie7,ff的区别
斜45度寻路实现函数

Javascript中的var_dump函数实现代码


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

发现了一个非常好的JavaScript调试方法,目前看到的是可以打印Object/Array/Function/String四种类型,使用方法和PHP中的var_dump()一样,只要直接dump(变量名)即可。 发现了一个非常好的JavaScript调试方法,目前看到的是可以打印Object/Array/Function/String四种类型,使用方法和PHP中的var_dump()一样,只要直接dump(变量名)即可。
复制代码 代码如下:

dump(value, [showTypes])
@ param value (Any) value to dump
@ param [showTypes] (Boolean) optional to display each key/value's type
@ return (Void) returns nothing

The Dump method is based on one of the tags available in Coldfusion ( <cfdump>) providing the ability to display simple and complex variables in a user friendly way that is perfect for debugging/inspecting data. There is no way to do this with javascript and often I had wanted a method to do this. This method will do just that allowing for an infinite amount of data nesting complete with color coding for different data types, the ability to show/hide the data's type (String/Number/Boolean/Object/Array/Function), expandable and collapsible tables/keys and cross browser support.
Click on the buttons bellow to see some examples in action, toggle the Show Data Types box to see javascript data typing in action (not possible in Coldfusion).
Browser Support
Internet Explorer 6, Internet Explorer 7, Firefox 1.5, Opera 8, Safari 1.2 (Mac), Firefox (Mac) - all tested, should also work in most other browsers
Dump Examples
官方网址
http://www.netgrow.com.au/files/javascript_dump.cfm
相关文件
http://www.netgrow.com.au/assets/files/dump/dump.zip
以防上面的地址下载不了,软晨学习网本地下载地址
jiaoben/20804.html">http://www.ruanchen.com/"http://www.ruanchen.com" style="color: #000">jiaoben/20804.html