魔鬼的细节:一个对Javascript的十年误解
早上不小心瞟到一篇文章,How Logical AND and OR Operators Actually Work in Javascript,才发现虽然我写了超过10年Javascript,却从来不知道这样的真相!
先说说这个误解,两个常用,及其简单的表达式:
private Helper helper = null; public Helper getHelper() { if (helper == null) { synchronized(this) { if (helper == null) { helper = new Helper(); } } } return helper; }