Automatically console.log the name and value of all variables in a script
<p>I often find one of the most repetitive tasks when writing JavaScript is the need to constantly check the value of variables, especially as a script grows more complex.</p>

<p>Is there a way to automatically log the variable values to the console via calling a function?</p>

<p>e.g.</p>

<pre><code>var foo = 1,
    bar = true,
    yin = ['item 1', 'item 2'],
    yang = 'a string',
    tan = $(this);

function() {
    yang = 'another string';
}

foo += 1;

yin.push('item 3');

function logMyVariables();
</code></pre>

<p>would log:</p>

<pre><code>foo: 2
bar: true
yin: item1, item2, item 3
yang: another string
tan: [object Object]
</code></pre>