原创 1.class繼承

// //類的定義 // class Animal { // constructor(name){ // this.name= name ; // } // sayName(){ // console.log("我的名字是"+this.n

原创 6.Set,沒有重複元素的集合

//set對象允許你存儲任何類型的唯一值,無論是原始值或者是對象引用   // const set1 = new Set([1,2,3,4]);   // alert(set1.has(1)) //has可以判斷這個值是否在這個裏面 返回

原创 一,用好filter,map,和其他高階便利函數

const arrContainsEmptyVal = [3, 4, 5, 2, 3, undefined, null, 0, ""]; const compact = arr => arr.filter(Boolean);   // c

原创 3.解構

//以一定的模式自動解析數組或者對象的值 // [name,,age]=['wayou','male','secrect'];//數組解構 // console.log('name:'+name+', age:'+age);//輸出: n

原创 4.默認參數,不定參數,擴展參數

// 1.默認參數 // var age = 18 // class Default{ // constructor(name=`dube`){ // this.name = name // } // sayName(){ // cons

原创 7.promise對象

/* 1.Promise 是異步編程的一種解決方案 相當於一個容器 可以獲取異步操作的小心 (1)有三個狀態:pending(進行中) fulfilled(已成功) rejecter(已失敗)   (2)一旦改變,就不會再變只能從pend

原创 5.for in和for of值遍歷

var x   var mycars = ["a","b","c"] for (x in mycars) { console.log(mycars[x]) console.log(x) } //for in遍歷,每次循環它提供的序號而不是

原创 二,理解和使用reduce

const reduce = (f, acc, arr) => { if (arr.length === 0) return acc; const [head, ...tail] = arr; return reduce(f, f(hea

原创 2.字符串模板

var num = "你好啊"; alert(`${num}`) function say(){ alert("你好啊") } 語法:1.使用反引號 ``            2.使用${x}將需要引入的東西包裹起來   console

原创 語法

ECMAScript的語法大量借鑑了C及其他類語言。 3.1.1 區分大小寫 比如Test和test分別表示兩個不同的變量但是函數名不能使用typeof,因爲他是一個關鍵字,但是typeOf完成可以 可以作爲一個有效的函數名 3.1.2