標籤:ECMAScript6預計將在 2015年6月 正式發布chrome測試文法需要引入Traceur編輯器https://github.com/google/traceur-compiler瞭解未來的文法和趨勢, 未來1年內估計也用到不, 這裡只做基本的瞭解.let 變數聲明{ let a = 10; //只在代碼塊內有效,適用於for,if等方法體 var b = 20;}console.log(a); //
標籤:3SumGiven an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of
標籤:一、建構函式 new object() new object(value) value:可以是數字,布爾值或字串,這些值將轉換為Number、Boolean或者String對象。二、屬性 object.constructor 所有對象的constructor屬性都指向當前對象的建構函式的那個函數。 var arr = new Array(1, 2, 3); document.write(arr.constructor);
標籤:一、建立對象 1、對象直接量。 var point = { x:0,y:0 }; //point就是一個對象,跟C#不同,它不需要一定有類才能建立對象。 2、通過new建立對象 var d = new Date(); //建立一個Date對象 3、原型 Object.prototype //用於擷取對象原型的引用。所有對象都直接或間接繼承自Object.prototype,相當於C#中的System.Object(); 通過new
標籤:一、new Boolean(value); //建構函式 Boolean(value); //轉換函式 0,NaN,null,"",undefined都會轉成false,其他都會返回true,包括字串"false" var b = new Boolean(1); //new也可以寫,就相當於上面的第二個建構函式
標籤:一、eval() //執行一段字串中的javascript代碼。 文法:eval(code); //可以將javascript寫在字串裡面執行。 var str = "document.write(‘你好!‘);" eval(str);二、EvalError() 建構函式: new EvalError(); new EvalError(message);三、parstInt() 從字串中解析整數 var