40
loading...
This website collects cookies to deliver better user experience
“A man is only as good as his tools.”
― Emmert Wolf
console.log()
. Though the console object has got a shedload of features — very few get explored.console.log()
many times.console.table()
?Be patient, the tables will turn.
(And if they won’t, make them turn.)
— The Ruhaniyat
“People try to hold onto the sameness. This holding onto prevents growth.”
— Bruce Lee
%c
variable for styles to be applied from the parameters.“Colour to the eye what music is to the ear.”
— Louis Comfort Tiffany
console.log()
console
**.**
dir()
displays an interactive list of the properties of the specified JavaScript object. The output is presented as a hierarchical listing with disclosure triangles that let you see the contents of child objects.dir
and log
on document.body
console.log()
prints the element in an HTML-like tree and console.dir()
prints the element in a JSON-like tree.console.log()
gives special treatment to DOM elements, whereas console.dir()
does not. This is often useful when trying to see the full representation of the DOM object.console.dir()
is the way to see all the properties of a specified JavaScript object in the console by which the developer can easily get the properties of the object.console.group()
we can group different console outputs together to show a form of relationship among them.“Many of the things you can count, don’t count. Many of the things you can’t count, really count.”
— Albert Einstein
console.Count()
command can help out.It is truth that liberates, not your effort to be free.
— J. Krishnamurti
console.assert()
comes quite handy when you only want to print some selected logs i.e. it will only print the false argument. It does nothing at all if the first argument is true.console.trace()
to get a quick and easy stack trace to better understand code execution flow.console.trace()
will log to the console the call stack that exists at the point console.trace()
was called.console.trace()
can be very helpful especially, in a large codebase where we have established that the code has a bug in it somewhere but, we aren’t sure exactly where it is.console.time()
one can get an idea of how long a certain section of code is taking.“Time is a created thing. To say ‘I don’t have time’, is like saying, ‘I don’t want to.”
― Lao Tzu
console.table()
gives b*etter visualization of data.***console.log( )**
we can have**console.info( )**
| **console.debug( )**
| **console.warn( )**
| **console.error( )**
%c
variable and use various CSS styling options.%s
%d
%i
%f
%o
that can determine format of the output.console.dir()
prints a JSON representation of the specified object.console.group()
can be used for grouping messages in the console.console.count()
logs the number of times that this particular call to count()
has been called. This function takes an optional argument label
.console.trace()
method displays a trace that show how the code ended up at a certain point.console.assert()
prints a statement when it is false.console.time()
can be used to track the micro-time taken for JavaScript executions.