Debug javascript in smarter way console.table()
by Awesome Geek in Javascript 0
Via mariusschulz.com
LOGGING ARRAY DATA WITH CONSOLE.LOG()
var languages = [
{ name: "JavaScript", fileExtension: ".js" },
{ name: "TypeScript", fileExtension: ".ts" },
{ name: "CoffeeScript", fileExtension: ".coffee" }
];
console.log(languages);
console.log() call will give you the following representation of your data:console.table().LOGGING ARRAY DATA WITH CONSOLE.TABLE()
console.log(), we'll use console.table() now:console.table(languages);
undefined values. Still, the property values are neatly arranged and give you a good overview.LOGGING OBJECT DATA WITH CONSOLE.TABLE()
console.table() is that it also works with objects:var languages = {
csharp: { name: "C#", paradigm: "object-oriented" },
fsharp: { name: "F#", paradigm: "functional" }
};
console.table(languages);
FILTERING THE DISPLAYED OBJECT PROPERTIES
console.table() call:// Multiple property keys
console.table(languages, ["name", "paradigm"]);
// A single property key console.table(languages, "name");Via mariusschulz.com
