Home > Web Front-end > JS Tutorial > JavaScript debugging console.table()

JavaScript debugging console.table()

coldplay.xixi
Release: 2020-07-06 16:57:40
forward
2851 people have browsed it

JavaScript debugging console.table()

Yesterday I learned about a small debugging method of the Chrome debugging tool. During WDCC, Marcus Ross (@zahlenhelfer) introduced various debugging methods of the Chrome debugging tool. This is just one of them. Now let me show it to you.

Use CONSOLE.LOG() to display the array

Imagine you constructed the following array

var languages = [
{ name: "JavaScript", fileExtension: ".js" },
{ name: "TypeScript", fileExtension: ".ts" },
{ name: "CoffeeScript", fileExtension: ".coffee" }
];console.log(languages);
Copy after login

console.log() will display the array like this

JavaScript debugging console.table()

This kind of display format is very useful for development, but I find it a bit cumbersome to manually click on each Object. At this time, I think console.table() is a bit interesting.

Use CONSOLE.TABLE() to display arrays

Now let’s try using console.table():

JavaScript debugging console.table()

Very small and wooden have?

Of course, console.table() is more suitable. The data is flatly listed in table format and displayed more perfectly. Otherwise, if each array element has a different structure, many grids in your table will be undefined.

Use CONSOLE.TABLE() to display object

Another feature of console.table() is to display object.

var languages = {
csharp: { name: "C#", paradigm: "object-oriented" },
fsharp: { name: "F#", paradigm: "functional" }
};

console.table(languages);
Copy after login

JavaScript debugging console.table()

Properly.

Filtering function of CONSOLE.TABLE()

If you want to limit console.table() to display a certain column, you can pass in the keyword list in the parameter as follows:

// Multiple property keys
console.table(languages, ["name", "paradigm"]);
Copy after login

If you want to access a property, one parameter is enough,

// A single property key
console.table(languages, "name");
Copy after login

I once thought that I had understood most of the functions of Chrome developer tools, but now I am obviously wrong, Sao Nian If you have nothing to do, check out the Chrome DevTools documentation!

Related learning recommendations: javascript video tutorial

The above is the detailed content of JavaScript debugging console.table(). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:webhek.com
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template