Method for using Console for JavaScript debugging

This article mainly introduces the method of using Console’s JavaScript debugging, has a certain reference value, and friends who need can refer to it. I hope that everyone has a big gain after reading this article. Let’s take a look at you with everyone.

In the past decade, one of my most passionate things is the front-end development (especially JavaScript). As a “craftsman, I like to study various tools. In this article, I will introduce you to some skills that use old-fashioned console to debug.

Yes, we all know the basic skills below:

Console.log (‘Hello World!’); (‘Something Happend …’) Console.warn (‘Something Strange Happend …); console.error (‘ Something Horrible Happened … ‘);
  From now on, I will teach you some you don't know. Skills, let you become old drivers!  1. Console.Trace () 
If you want to know where the message is printing, use

console.trace ()

to get the StackTrace of the data you want to print. .

2. Console.time () && console.TimeEnd () If you want to analyze the performance of the function, you can use

Console.Time ()

console.TimeEnd () 使用Console进行javascript调试的方法 to end the timing, the console will print a time difference between twice.

3. Console.memory

If you find that performance problems are difficult to analyze, it may also be considered whether there isTo exist, you can use Console.Memory (Note Memory is the properties of Console, not a function) to view the current stack.

Fundebug helps you better debug, welcome to try! 使用Console进行javascript调试的方法 4. Console.profile (‘ProfileName’) & console.profilend (‘ProfileName’)

Although it is not a standard approach, it is not widely accepted. You can use these two commands to start and stop Profiling. This helps you make precise profile in your code. Not relying on manual mouse click. You can find the just profile in the browser console

Javacript Profiler

. 5. Console.count (“stuff i count”)

Sometimes, in order to record a function or how many times is repeated, it can be repeated. Use 使用Console进行javascript调试的方法 Console.count (‘?’)

to record. Every time you execute it, you will be automatically added.

6. Console.assert (False, “Log ME!”)

You can use console.assert Output messages under false conditions instead of using IF-ELSE.

Note: An error will be reported under node.js.

使用Console进行javascript调试的方法 7. (‘group’) & console.groupend (‘group’)

If you want to make a format for the printed log Correlation, you can use

Console.Group ()

and Console.groupend () . Use to aggregate into groups, and form a nesting hierarchy. That example:

8. String Substitutions 使用Console进行javascript调试的方法

You can use


print variable (% s = String,% I = INTEGER,% o = Object,% f = float).

9. Console.clear () We have already output a lot of records in the console to use
console.clear ()


10. Console.table () 使用Console进行javascript调试的方法

The last pressure axis! You can use

Console.Table ()

to print the object in the form of a table.

Thank you can read this article carefully, I hope that Xiaobian sharing the method of using console for JavaScript debugging, and also helps you support Tumi Cloud Pay attention to Tumi Cloud Industry Information Channel. If you have problems, you will find Tumi clouds, and the detailed solution is waiting for you!

© Copyright Notice
Just support it if you like
comment Grab the couch

Please log in to comment