Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have just read some parts of his Crockfords book "Javascript: The Good Parts". I get the feeling that he considers everything that ever has bitten him as harmful:</p> <p>About switch fall through:</p> <blockquote> <p>I never allow switch cases to fall through to the next case. I once found a bug in my code caused by an unintended fall through immediately after having made a vigorous speech about why fall through was sometimes useful. (page 97, ISBN 978-0-596-51774-8)</p> </blockquote> <p>About ++ and -- </p> <blockquote> <p>The ++ (increment) and -- (decrement) operators have been known to contribute to bad code by encouraging exessive trickiness. They are second only to faulty architecture in enabling viruses and other security menaces. (page 122)</p> </blockquote> <p>About new:</p> <blockquote> <p>If you forget to include the <em>new</em> prefix when calling a constructor function, then <em>this</em> will not be bound to the new object. Sadly, <em>this</em> will be bound to the global object, so instead of augmenting your new object, you will be clobbering global variables. That is really bad. There is no compile warning, and there is no runtime warning. (page 49)</p> </blockquote> <p>There are more, but I hope you get the picture.</p> <p>My answer to your question: <strong>No, it's not harmful.</strong> but if you forget to use it when you should you could have some problems. If you are developing in a good environment you notice that.</p> <p><strong>Update</strong></p> <p>About a year after this answer was written the 5th edition of ECMAScript was released, with support for <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope/Strict_mode" rel="noreferrer">strict mode</a>. In strict mode, <code>this</code> is no longer bound to the global object but to <code>undefined</code>.</p>
 

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