Get more mileage from your console output by going beyond mere string logging - log entire introspectable objects, log multiple items in one call, and apply C-Style string substitution to make the console work for you.
// Can accept multi args console.log("Hello", "World", "2016"); // Hello World 2016 // Can accept any Javascript type console.log({foo: "bar", foobar: {bar: "foo"}}); // Substitution console.log("Hello my name is %s, %d years age, object ->", "Zhentian", 23, {name: "Zhentian"}); // Hello my name is Zhentian, 23 years age, object -> Object {name: "Zhentian"} // Styling output console.log("Listen, this is %cimportant!", "font-size: 24px; color: red");
时间: 2024-10-13 09:48:11