Today, I had a typo that was hard to catch because it wasn't throwing an error as I would have expected...
After some quick testing the code below always returns true, and obviously, in this case returns 'first'. Why does this happen? And why doesn't it produce an error?
Here is a simple example of the code:
function func(num) {
return num = 5 ? 'first' : 'second';
}
console.log(func(1)); // log 'first'
My linter caught it, but I was in a JSBin initially and didn't notice.