字符串能夠使用''或者是""html
==
只比較內容===
比較內容,也比較類型是否同樣,兩個爲true才爲true!==
與上面===
相反var a=123; var b="123"; //a==b 結果爲true //a===b 結果爲false //a!==b 結果爲true
js中的變量是全局性的,局部相同的變量名也會更改原來的數據es6
var i=2; for(var i=0;i<5;i++){ console.log('hello'); } console.log(i);//這裏的i等於4
let
局部變量的關鍵字,不會修改到全局的變量windows
var i=2; for(let i=0;i<5;i++){ console.log('hello'); } console.log(i);//這裏的i等於2
js從上到下編譯,可是,若是方法是在後面的話,也能夠執行方法,即便尚未進行方法的編譯數組
//console.log(hello); 打印函數內容 //console.log(hello()); 打印函數內容,以後執行函數 hello(); function hello(){ console.log("hello world!"); }
方法返回無需在方法前面定義返回類型函數
function print(){ return ""; }
querrySelectorcode
querrySelector是jQuery中的方法innerHtml
若是文本有html,能夠識別文字裏面的html標籤innerText
只能放入文本,不會識別其中的標籤htm
body標籤 onload 至關於windows.onloadip
//es6中,year和month是變量 換行直接換,不須要「+」 var str = `${year}年${month}月`; //會保留空格以及換行 var str = `${year}年 ${month}月`
var e = document.getElementById("h"); //e存在爲true,不存在則爲false if(e){ }
var array1 = ["a","b","c"]; array1.foreach(function(element){ console.log(element); });