2 js的20/80關鍵知識
阿新 • • 發佈:2017-12-31
nbsp highlight style sele undefine bubuko gpo ima .com
1.
2
var a = 1; undefined a 1 alert(a); undefined
var b = true; var c = "Hi"; undefined alert(b); alert(c); undefined
function foo(bar){ alert(bar); return bar; } undefined var z = foo("Hi"); undefined z "Hi"
function foo(bar) { alert(bar); return bar; }
- shift+enter 換行
function foo(bar){ if (bar > 3){ alert(bar + 1); } else { alert("Not enough"); } } undefined foo(5) undefined foo(2); undefined
3
var arr = [] undefined function foo(bar){ if (bar > 3){ arr.push(bar); } else { alert("Not enough"); } } undefined foo(2); undefined foo(6); undefined arr; [6]
var o = { one:1, two:2 } undefined o.one 1 o.two 2
4
document #document document.querySelector("#sidebar") <div id=?"sidebar">?…?</div>? var el = document.querySelector("#sidebar"); undefined el <div id=?"sidebar">?…?</div>? el.setAttribute("style","display:none;") undefined
5
6
2 js的20/80關鍵知識