Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to distinguish strings from ints in firebug console
    primarykey
    data
    text
    <p>I need to distinguish <code>"0"</code> from <code>0</code> in Firebug <code>console.log</code> output. </p> <p>If you type <code>console.log("0")</code> into Firebug console, you'll get <code>0</code>, same as if you'd typed <code>console.log(0)</code>, but I need it to be <code>"0"</code>.</p> <p>In other words, <strong>expected</strong> output:</p> <pre><code>console.log("0") &gt; "0" console.log(0) &gt; 0 </code></pre> <p><strong>Actual</strong>:</p> <pre><code>console.log("0") &gt; 0 console.log(0) &gt; 0 </code></pre> <p>What is the best solution to this problem?</p> <p>I've found some workarounds like <code>console.log("%o", "0")</code> or <code>console.log(["0"])</code>, but they are too clumsy and obtrusive to use them everywhere.</p> <p>I've also tried <code>debug</code> and <code>info</code> without success.</p> <p>By the way, Chrome console gets it right, but I'm not ready to move to Chrome yet.</p> <p>I'm thinking about writing some wrapper around console object. I'm not sure how to do it right but I'll try it if there is no other solution.</p> <hr> <p>So, the only solution seems to be that you need make some wrapper that looks like this (based on @wsanville's answer):</p> <pre><code>var log_orig = console.log; // No need to check for type, just use %o for everything // Also, it gets messier for multiple arguments console.log = function(s) { log_orig('%o', s); } </code></pre> <p>But then you get the problem with line numbers, as described in <a href="https://stackoverflow.com/questions/3336316/how-to-access-line-numbers-when-wrapping-firebug-or-similar-console-api">How to access line numbers when wrapping Firebug (or similar) Console api</a></p> <p>I guess I should file a firebug bug or something, because this can be really critical in some situations.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload