/** * Created by W.J.Chang on 2014/5/23. */ // 判读是否是数组的方法 console.log(Array.isArray(new Array)); console.log(Array.isArray([])); var arr = [1,2,3]; // 遍历方法 arr.forEach(function (v){ console.log(v); }); console.log("---------------------"); // 过滤但不改变原数组 arr.filter(function (v){ return v < 3; }).forEach(function(v) {console.log(v);}); arr.forEach(function (v) { console.log(v); }); console.log("---------------------"); // 改动但不改变原数组 arr.map(function (v){ return v * 3; }).forEach(function(v) {console.log(v);}); arr.forEach(function (v) { console.log(v); }); console.log("---------------------"); [1,2,3].map(function(v){return v*2}).forEach(function(v) {console.log(v);}); //字符串 console.log(" hello ".trim()); // JSON 处理 var obj = JSON.parse('{"a":"b","c":"d"}'); console.log(obj.a); console.log(JSON.stringify(obj)); // bind 改变this的引用 function a(){ this.hello == "world"; } var b = a.bind({hello:'world'}); // name 函数名 var aa = function woot(){}; console.log(aa.name);