Home >Web Front-end >JS Tutorial >Var_dump function implementation code in Javascript_javascript skills

Var_dump function implementation code in Javascript_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:47:171424browse

I found a very good JavaScript debugging method. What I have seen so far is that it can print four types: Object/Array/Function/String. The usage method is the same as var_dump() in PHP. Just dump (variable name) directly.

Copy code The code is as follows:

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 ( ) 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
Official website
http://www.netgrow.com.au/files/javascript_dump.cfm
Related files
http://www.netgrow.com.au/assets/files/dump/dump.zip

In case the above address cannot be downloaded, Script Home local download address
http://www.jb51.net/jiaoben/20804.html
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