-
赋值定义查看全部
-
//捕获错误 try { //document.write(b);//错误语句 throw new Error("error-_-"); document.write("捕获错误!"+'<br />'); } catch(e) { document.write("错误了:"+e+'<br />'); } finally { document.write("不管是否错误,都会执行!"+'<br />'); }查看全部
-
类型检测小结查看全部
-
返回类型查看全部
-
//测试输出 console.log("888"); function fun() { var a=b=100;//b其实是全局变量,如果分开定义则不会出这种问题var a = 100, b= 100; document.write("a:"+a); document.write("b:"+b); } fun(); document.write("b:"+b);//因为b是全局变量,在这里是有值的100查看全部
-
不严格等于,类型相同跟严格等于一样,类型不同尝试转换类型查看全部
-
/* //条件预算符 var tag = 8; var result = (tag == 5)?"等于":"不等于"; document.write(result); //逗号表达式 var dou = (1,2,3); document.write(dou); var i = 10; var dou = (++i,++i,++i); document.write(dou); var dou = (a=1,b=2,c=8); document.write(dou); document.write(a); document.write(b); //删除变量的属性 var a = {x:"x属性"} document.write(a.x);//x属性 delete a.x; document.write(a.x);//undefined //设置属性无法删除 >ie9 var b = {x:"x属性"}; document.write(b.x);//x属性 Object.defineProperty(b,'x',{configurable:false,value:"后来设置的值"}); delete b.x; document.write(b.x);//后来设置的值 //判断对象是否有某个属性 var c = {x:'x属性'}; alert('x' in b);//true alert('y' in b);//false */ // function Obj() { this.x = "x属性"; this.fun = function(){document.write("Obj的fun方法");}; }; Obj.prototype.y = "y属性";//prototype* Obj.prototype.fun2 = function(){document.write("Obj的fun2方法");}//prototype* //document.write(Obj.x);//undefined 不能这样用 var a = new Obj(); document.write(a.x); document.write(a.y); a.fun(); a.fun2();查看全部
-
严格等于查看全部
-
var obj = {x:"x",y:"y"}; obj.fun = function(){document.write("heool");}; document.write(obj.x); obj.x = "yyyy"; document.write(obj['x']); obj.fun(); var obj1 = new Object;//创建空对象 obj1.x = "属性1"; obj1.fun = function(){document.write("obj1方法");}; document.write(obj1.x); obj1.fun();查看全部
-
/*alert([1,2] instanceof Array);//true function objf(){}; function objf1(){}; var a = new objf(); var b = new objf1(); alert(a instanceof objf);//true alert(b instanceof objf);//false */ var objFunction = function(){}; alert(Object.prototype.toString.apply(objFunction));//[object Function] alert(Object.prototype.toString.apply([1,2,3]));//[object Array] alert(Object.prototype.toString.apply(null));//[object Null] alert(Object.prototype.toString.apply(10));//[object Number] alert(Object.prototype.toString.apply("str"));//[object String] alert(Object.prototype.toString.apply(false));//[object Boolean] alert(Object.prototype.toString.apply(undefined));//[object Undefined]查看全部
-
/*var str = "string"; document.write(str[0]); alert(str.length); str.t = "test"; alert(str.t);//undefined var strObj = new String("string"); document.write(strObj[0]); alert(strObj.length); strObj.t = "test"; alert(strObj.t);//test strObj.fun = function(){alert('strObj.fun');}; strObj.fun();//strObj.fun*/ //类型检测 //typeof 适合基本类型,函数的检测,遇到null返回object /*alert(typeof(1));//number alert(typeof(NaN));//number var arr = new Array(1,2,3); alert(typeof(arr));//object alert(typeof("string"));//string alert(typeof(null));//object (注意) alert(typeof(undefined));//undefined alert(typeof(false));//blooean function a() { document.write(888); } alert(typeof(a));//function */查看全部
-
原型链的学习查看全部
-
JavaScript通过原型链实现继承查看全部
-
不明觉厉的原型链查看全部
-
严格模式总结查看全部
举报
0/150
提交
取消