How JavaScript prints objects

Source: Internet
Author: User
Tags print object

In js debugging, when the output content is an object and cannot be printed, alert can only print the object identifier, but cannot print the content. This is inconvenient, as a result, we have summarized the following code:

Function writeObj (obj) {var description = ""; for (var I in obj) {var property = obj [I]; description + = I + "=" + property + "\ n";} alert (description );}

In addition, when you need to convert an object to a string, you can refer to: js to convert an Object to a String function code.

Articles you may be interested in
  • Js print array, js Print Object Method
  • JavaScript to print pages
  • Javascript to get the current mouse position (compatible with IE and firefox)
  • Js restrictions: Only English letters and numbers can be entered. Chinese characters and other special characters cannot be entered.
  • Thinkphp prints the last SQL statement
  • Invincible firewheel effect in the address bar of JavaScript Browser
  • Use JavaScript to verify the regular expression of the mobile phone number
  • How to obtain the complete url address and parameters in javascript

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.