Firebug console Function Description

Source: Internet
Author: User

Firebug is a very practical debugging tool for JavaScript and Dom viewing. It is a plug-in of Firefox. It is very convenient to use firebug to debug Ajax applications. Finally, we can say goodbye to the alert era!
Console Logging Function

Firebug provides a console object for all web pages. This object has the following functions:
Logging Basics
Console. Log ("message"
[, Objects])-print a string to the console. A string can contain any "string"
Formatting "section describes the mode. The object after the string should be used to replace the pattern in the previous string. (Translator's note: I used printf in C.
The results are basically the same .)
Logging level

It is helpful to distinguish the severity of logging based on different levels. Firebug provides four levels. To achieve visual separation, these functions are different from log in that they automatically contain a link pointing to the number of lines of code when called.
Console. debug ("message" [, objects])-record a debug message.
Lele.info ("message" [, objects])-records an information.
Console. Warn ("message" [, objects])-record a warning.
Console. Error ("message" [, objects])-record an error.
Assertions

Assertions are a good way to ensure Code rules. The console object contains a series of various types of asserted functions and allows you to write your own asserted functions.
Console. Assert (a, "message" [, objects])-asserts that an A is true.
Console. assertequals (a, B, "message" [, objects])-asserts that A is equal to B.
Console. assertnotequals (a, B, "message" [, objects])-asserts that A is not equal to B.
Console. assertgreater (a, B, "message" [, objects])-asserts that A is greater than B.
Console. assertnotgreater (a, B, "message" [, objects])-asserts that A is not greater than B.
Console. assertless (a, B, "message" [, objects])-asserts that A is less than B.
Console. assertnotless (a, B, "message" [, objects])-asserts that A is not less than B.
Console. assertcontains (a, B, "message" [, objects])-asserts that A is in the array B.
Console. assertnotcontains (a, B, "message" [, objects])-asserts that A is not in the array B.
Console. asserttrue (a, "message" [, objects])-asserts that A is equal to true.
Console. assertfalse (a, "message" [, objects])-asserts that A is equal to false.
Console. assertnull (a, "message" [, objects])-asserts that A is equal to null.
Console. assertnotnull (a, "message" [, objects])-asserts that A is not equal to null.
Console. assertundefined (a, "message" [, objects])-asserts that A is equal to # ff0000.
Console. assertnotundefined (a, "message" [, objects])-asserts that A is not equal to undefined.
Console. assertinstanceof (a, B, "message" [, objects])-asserts that A is an instance of type B.
Console. assertnotinstanceof (a, B, "message" [, objects])-asserts that A is not an instance of type B.
Console. asserttypeof (a, B, "message" [, objects])-asserts that the type of A is equal to the string B.
Console. assertnottypeof (a, B, "message" [, objects])-asserts that the type of A is not equal to the string B.
Measurement)

The following functions allow you to conveniently measure some of your code.
Console. Trace ()-record the stack information of the execution point.
Console. Time ("name")-create a unique timer based on the name.
Console. timeend ("name")-stop the timer based on the name and record the time consumed, in milliseconds.
Console. Count ("name")-records the number of times the code is executed for this row.
String formatting

All logging functions of the console can format strings in the following mode:
% S-format the object as a string.
% D, % I, % L, % F-format the object as a number.
% O-format the object into a hyperlink pointing to inspector.
% 1.o, % 2.0, Etc ..-format the object into an interactive table containing its own attributes.
%. O-format the object into an array with its own attributes.
% X-format the object into an interactive XML tree structure.
% 1.x, % 2.x, Etc ..-format the object into an interactive XML data structure and expand layer n nodes.

If you need a real % sign, you can use a transfer sign like this "\ % ".
Command line functions

The built-in command line functions can be used through the following command line:
$ ("ID")-short for document. getelementbyid. (Note: I learned from prototype. js ?)
$ ("CSS")-returns an array of elements that match the CSS selector.
$ X ("XPath")-returns an array of elements that match the XPath selector.
$0-returns the object that was recently checked (inspected.
$1-return the next object that has been recently checked (inspected.
$ N (5)-returns the nth object most recently inspected.
Inspect (object)-displays the object in inspector.
Dir (object)-returns an array of object attribute names. (Note: I learned from Python ?)
Clear ()-clear console information.

Powerful JavaScript debugging tool: firebug Usage Details:
Http://blog.csdn.net/tianxiaode/archive/2007/09/02/1769152.aspx
First knowledge of firebug:
Http://www.ooso.net/index.php/archives/294

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.