http://developer.51cto.com/art/201209/355188.htm
下面有4组代码看似简单,但是却另人非常抓狂的,让人匪夷所思。喜欢研究探索的你快来看看吧……
AD:
1.确保这个值等于ture
- if (someBoolean == true) {
- doSomething();
- }
2.只有等于ture时我才return ture
- if (result == true)
- return true;
- else
- return result;
3.我就是不信任if
- if (result <= 10) {
- handling();
- }
- else if (result > 10) {
- otherHandling();
- }
- else {
- handling(); // to be sure
- }
4.要写出一看就懂的代码
- function DocumentDotWrite(s){
- document.write(s);
- }