字符串能够使用''或者是""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); });