隐式转换 + ??- num - 0 把num转换成number;num + "" 把num转换成字符串;-------------------------------------------------------------------------常见的:null == undefined;NAN不等于NAN;===指的是值和类型相等;(严格判断);-------------------------------------------------------------------------函数申明:function aa(){}函数表达式: 1...var aa = function(){}2...(function(){})()3...return funtion(){}4....var aa = function xx(a,b){}遍历:for(item in obj){//顺序不确定//enumerable为false时不会出现//for in对象属性时受原型链影响}-------------------------------------------------------------------------创建对象:字面量的形式、Object.create();对象的get/set方法var obj = { ??name:"bob", ??sex:"man" ??get age(){ ?????return new Date.getFullYear() - 1993; ??}, ??set age(val){ ?????console.log("年龄未被设置" + val) ??}}console.log(obj.age) //输出25obj.age = 30;//提示没有被设置console.log(obj.age) //仍然输出25-------------------------------------------------------------------------function aa(x,y,z){ ??arguments.length; ?//2 ??arguments[0];//10 ??arguments[0] = 10 ; //绑定关系 ??x;//10 ??arguments[2] = 20 ; //没传参数,失去绑定关系 ??z; ?//still undefined}aa(1,2);aa.length; ?//3aa.name; ??//"aa"-------------------------------------------------------------------------
函数传参:参数类型:基本类型和引用类型(数字、数组、字符串、函数等)参数类型判断:typeof()单个参数可以省略括号。function fn1(){ ?console.log("let go")}function fn2(v){ ?if(typeof v === "function"){ ???v() ?}}fn2(fn1())数组:通俗理解就是变量的有序集合arr = [];arr = new Array();两种方式是等效的创建数组;数组支持嵌套 如:arr = [数值,{对象},[数组],fn]多维数组如:arr = [[1,2,3],[4,5,6],[7,8,9]]function test(){}test(); ?---->A0{}test(); ?---->AO{}函数执行完毕即时清除AO。(AO代表上下文对象)js里面空格也是合法的字符串str.length;性能for循环的性能问题:不要直接去操控长度。原始:for(var i=0;i<res.length;i++){ ?alert(i) ----->//弹出res.length}修改性能后:var res = res.length;for(var i=0;i<res;i++){ ?alert(i) ----->//弹出res}
js由浅入深理解
原文地址:https://www.cnblogs.com/lhl66/p/8719336.html