javascript - Is it unprofessional to use console.log to debug JS?
phpcn_u1582
phpcn_u1582 2017-07-05 11:01:00
0
8
920

In the year since I taught myself front-end, I have been accustomed to using console.log to debug JS code.
But isn’t this approach very amateurish? Should I stop this habit and try using the browser's debugging tools?

phpcn_u1582
phpcn_u1582

reply all(8)
淡淡烟草味

1. About console
console implements access to the browser console.
In fact, in addition to the log method, the console also has many other advanced methods.
For example:

console.table();
console.group();
console.assert();

For specific usage, please refer to my blog http://www.jianshu.com/p/75cb...
2. About debugger
I recommend you to use vscodeThis god-level tool, since it has I haven’t touched much about vscode and sublime.
For front-end development, I personally feel that vscode is the culmination of sublime and chrome. It has rich plug-ins, easy debugging, and is very comfortable to develop.

阿神

This method is much better than alert. At least you don’t have to click to close it, and it leaves the answers you need

巴扎黑

Chrome’s network plus console debugging, I absolutely love it.
There is no bug that cannot be found in one console print. If there are two, then there are two.

漂亮男人

The goal of debugging is to solve problems. From the goal point of view, as long as it can solve the problem and save time, it is okay. Just like many people who engage in machine learning think that the front-end has no technical content, but think about it from another angle, front-end and machine learning Both can create value. In the final analysis, they all use computer basics and mathematical knowledge, which are all in logic. From this perspective, there is no difference in comparison.

给我你的怀抱

This is just a personal habit, it has nothing to do with professionalism or not. I just like console.log and don't like setting breakpoints everywhere.

代言

What is professionalism? In my opinion, professionalism is not defined by the more advanced and difficult techniques, but by adopting the most useful and effective methods under specific circumstances.

So, you must be able to use the browser’s debugging tools. However, if you can judge that console debugging is faster for specific problems, it is not unprofessional to use console.

世界只因有你

First of all, console is also a commonly used debugging method. Secondly, it depends on your personal usage habits. You can choose between console and debugger as appropriate. In some places, you only need to look at the printed values ​​and use console. In some places, you need to clarify the logic and use debugger

漂亮男人

As a person who writes both background Java and front-end pages, I feel that breakpoint debugging is much more efficient. The most important thing is that it is easier to find problems

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template