为了账号安全,请及时绑定邮箱和手机立即绑定

JavaScript深入浅出

Bosn 资深架构师
难度中级
时长 5小时28分
学习人数
综合评分9.60
493人评价 查看评价
9.8 内容实用
9.5 简洁易懂
9.5 逻辑清晰
  • var arr = [1,2,3]; delete arr[0]; console.log( arr ); // [undefined,2,3] arr.length; // 3 1 in arr; // false arr.length -= 1; console.log( arr ); // [undefined,2] ,3 is removed arr.pop(); // e returned by pop console.log( arr ); // [undefined] , 2 is removed
    查看全部
  • 序列化 var obj = {val:undefined, a:NaN, b:Infinity, c:new Date()}; JSON.stringfy(obj); // "{"a":null,"b":null,"c":"2015-01-20T14:15:43.910Z"}"
    查看全部
  • with(document.forms[0]){ console.log(name.value); } 等同于: var form = document.forms[0]; console.log(form.name.value);
    查看全部
  • var yz; if(obj.y){ yz = obj.y.z; } // 等同于 var yz = obj && obj.y && obj.y.z; var person = {age:28,title:'fe'}; delete person.age; // true delete person['title']; // true // delete 某对象属性-->true,只是代表这个对象上没有此属性了 delete Object.prototype; // false 不能删除 var descriptor = Object.getOwnPropertyDescriptor(对象,'属性'); // 查看某对象的某属性 --> 属性描述器,也是一个对象 descriptor.configurable; // false 除了对象的属性可以使用 delete 删除,eval()中定义的变量可以,还有: ohNo = 1; // 隐式定义的变量 window.ohNo; // 1 delete ohNo; // true Object.defineProperty(cat,'price',{enumerable:false,value:1000}); // 默认为false if(cat.legs != undefined){} // !== undefined,or,!== null if(cat.legs !== undefined){} // only if cat.legs is not undefined
    查看全部
  • function 的[[proto]] --> Object.prototype -- null function foo(){} foo.prototype.z = 3; var obj = new foo(); obj.z; //3 typeof obj.toStirng; // 'function' 'z' in obj; // true; obj.hasOwnProperty('z'); // false obj.z=5; // 若 obj 上没有 z 这个属性,就添加,有的话就修改值 obj.hasOwnProperty('z'); // true foo.prototype.z; // still 3 obj.z; // 5 obj.z = undefined; ojb.z; // undefined --> delete obj.z; // true 删除 obj 上的 z obj.z; // 3 var obj = Object.create({x:1}); obj.x; // 1 typeof obj.toString // "function" obj.hasOwnProperty('x'); // false var obj = Object.create(null); obj.toString // undefined
    查看全部
  • var obj = {}; obj[1] = 1; obj['1'] = 1; // []里面的 转换成 字符串 obj; // Object{ 1 : 2} obj[{}] = true; obj[{ x : 1}] = true; obj; // Object{ 1:2, [object Object]:true} function foo(){} foo.prototype.z = 3; var obj = new foo(); 对象有:[[proto]]、[[class]]、[[extensible]] 对象的属性有:writable、enumerable、configurable、value、get/set
    查看全部
  • 设置属性值的时候如果当前对象没有这个属性则向上查找到原型上的这个属性,但是如果原型上式通过get set方法来定义的这个属性,那么是不会设置成功的,如果原型上就是普通的属性赋值那么通过对象的属性设置是可以取到的 天哪好乱了
    查看全部
  • 啦啦啦
    查看全部
  • function arraysSimilar(arr1, arr2){ if(!(arr1 instanceof Array && arr2 instanceof Array)){ return false; } if(arr1.length !== arr2.length){ return false; } var obj = {}; for(var i = 0; i < arr1.length; i++){ obj[Object.prototype.toString.apply(arr1[i])] = 1; console.log(obj); }; for(var j = 0; j < arr2.length; j++){ if(!obj[Object.prototype.toString.apply(arr2[j])]){ return false; } }; return true; }
    查看全部
    0 采集 收起 来源:编程练习

    2018-03-22

  • 6. !function(){ // 'use strict'; // 禁止八进制字面量 console.log(0123); // 非严格模式下, 83 }(); 7. eval,arguments 变为关键字,不能作为变量、函数名 8. eval 独立作用域 !function(){ // 'use strict'; eval('var evalVal = 2'); console.log( typeof evalVal ); // 非严格模式下,number // 严格模式下 undefined }();
    查看全部
  • function func(){ 'use strict'; } 'use strict'; // 在整个 js 文件开头(可以放在第二行),指定整个js文件在严格模式下执行 function func(){ } 严格模式下 不能使用 with 不允许未声明的变量被赋值 1. function(a){ // 'use strict'; // 如果有的话,arguments 变为参数的静态副本 // 这样的话,不管 传参没传参,a 都将变为 100 arguments[0] = 100; console.log(a); }(); // --> 没有传参, a 为 undefined 2. function(a){ 'use strict'; argements[0].x = 100; console.log(a.x); // 100 }( { x : 1 } ); 3. !function(a){ //'use strict'; // 严格模式下, 会报错 console.log(delete a); // 不是严格模式下不会报错,返回 false }(1); 4. !function(a){ var obj = {}; Object.defineProperty(obj, 'a',{ configurable : false } ); // delete obj.a; // TypeError console.log( delete obj.a ); // false }(1); 5. !function(){ // 'use strict'; var obj = { x : 1, x : 2 }; // 严格模式下出错! console.log( obj.x ); // 非严格模式下,2 }();
    查看全部
  • 1. 顺序不确定 2. enumerable 为 false 时不会出现 3. for in 对象属性时受原型链影响 with({ x : 1 }){ console.log(x); } with( document.form[0] ){ console.log( name.value ); } var form = document.forms[0]; console.log( form.name.value ); with : 1. 让JS引擎优化更难 2. 可读性差 3. 可被变量定义代替 4. 严格模式下被禁用
    查看全部
  • * ES5 中没有块级作用域,但是有函数级作用域! var a = b = 1; // 隐式创建了全局变量 b ! var a=1,b=1; // a,b 都是局部变量
    查看全部
  • 1. var val = (1, 2, 3); // val =3; "," 运算符,值为最右边的 var obj = { x:1 }; obj.x; // 1 delete obj.x; // 删除 obj 的 x 属性 obj.x; // undefined 2. var obj = {}; Ojbect.definProperty(obj,'x',{ configurable: false, // 要为 true 才可以 delete value: 1 }); delete obj.x; // false obj.x; // 1 3. window.x = 1; 'x' in window; // true 4. {} instanceof Object // true typeof 100 === 'number' // true 5. function Foo(){} Foo.prototype.x = 1; var obj = new Foo(); obj.x; // 1 obj.hasOwnProperty('x'); // false obj._proto_.hasOwnProperty('x'); // true 6. this; // 若是全局变量 --> window (浏览器) var obj = { func: function(){return this;} // this --> 当前对象 }; obj.func(); // obj 7. void 0 // undefined void(0) // undefined
    查看全部
  • 1. typeof typeof(undefined) --> "undefined" typeof [1, 2] --> "object" typeof NaN --> "number" typeof null --> "object" 2. instanceof 判断对象 obj instanceof Object obj --> 必须是对象,否则直接返回 false Object --> 必须是个构造函数 [1, 2] instanceof Array === true new Object() instanceof Array == false 任何一个对象都有一个 prototype -- 对象原型属性 * 不同 window 或 iframe 间的对象类型检测 不能使用 instanceof ! 3. Object.prototype.toString Object.prototype.toString.apply([]); --> "[object Array]" Object.prototype.toString.apply(function(){}); --> "[object Function]" Object.prototype.toString.apply(null); --> "[object Null]" Object.prototype.toString.apply(undefined); --> "[object Undefined]" 4. constructor 这个可以改! duck type
    查看全部

举报

0/150
提交
取消
课程须知
1.您至少学习了本站“JS入门”、“JS进阶”两门基础课程。 2.如您具备一定实践经验对学习有很大帮助。 3.如您没有脚本编程开发经验,学习过程有可能会受挫部分内容或示例代码,请“暂时略过不懂的部分,后面章节会阐述”,当然想透彻学习,还需大量实践来体会知识的内涵。
老师告诉你能学到什么?
结合实例,深入解析以下知识内容: 1. 数据类型、表达式和运算符、语句; 2. 对象、数组、变量、函数; 3. this、闭包和作用域; 4. OOP; 5. 正则与模式匹配。

微信扫码,参与3人拼团

微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

友情提示:

您好,此课程属于迁移课程,您已购买该课程,无需重复购买,感谢您对慕课网的支持!