Using console.dir to Get The Property of DOM Element
If we use console.log to display the DOM element, we will get pure HTML only. What we have to do is using console.dir to get the property of the DOM element.
If we use console.log to display the DOM element, we will get pure HTML only. What we have to do is using console.dir to get the property of the DOM element.
If we care about the performance of some code snippets, we can use console.time to measure the performance.
If we use console.log in the for loop, it may produce too many debugging messages to read. It’s a good time to use the console.group to group them under a group.
Besides using console.log to display debugging messages, we can use console.table to display Array of Objects for a better layout.
Not only just showing debugging messages on the console of DevTools, but we can also use CSS to change their style.
If we want to add Object property at runtime, it chanced that we override property of original Object. Since Symbol is a unique value, using Symbol Property to prevent property from overriding.
If we only allow limited values for arguments, using Enums is a good choice. Unfortunately, we don’t have native Enums in JavaScript, but we can use Object and Symbol to simulate it.
Symbol is a new type for unique value in ECMAScript 2015.
ECMAScript 2015 introduced Array.prototype.entries, which returns index and element from Array.
If we want to get key and value from Object simultaneously, we used to use Object.keys to get all keys, and then use [] with the key to get value. Now we can use Object.entries to get key and value at once.