• JS ****************


    let [x, [y, z]] = ['hello', ['JavaScript', 'ES6']];
    x; // 'hello'
    y; // 'JavaScript'
    z; // 'ES6'
    

    let [, , z] = ['hello', 'JavaScript', 'ES6']; // 忽略前两个元素,只对z赋值第三个元素 z; // 'ES6' var person = { name: '小明', age: 20, gender: 'male', passport: 'G-12345678', school: 'No.4 middle school', address: { city: 'Beijing', street: 'No.1 Road', zipcode: '100001' } }; var {name, address: {city, zip}} = person; name; // '小明' city; // 'Beijing' zip; // undefined, 因为属性名是zipcode而不是zip // 注意: address不是变量,而是为了让city和zip获得嵌套的address对象的属性: address; // Uncaught ReferenceError: address is not defined
    var person = { name: '小明', age: 20, gender: 'male', passport: 'G-12345678', school: 'No.4 middle school' };
    // 把passport属性赋值给变量id: let {name, passport:id} = person; name; // '小明' id; // 'G-12345678' // 注意: passport不是变量,而是为了让变量id获得passport属性: passport; // Uncaught ReferenceError: passport is not defined
    var person = { name: '小明', age: 20, gender: 'male', passport: 'G-12345678' };
    // 如果person对象没有single属性,默认赋值为true: var {name, single=true} = person; name; // '小明' single; // true var x=1, y=2; [x, y] = [y, x]

    apply、call

    function getAge() {
        var y = new Date().getFullYear();
        return y - this.birth;
    }
    
    var xiaoming = {
        name: '小明',
        birth: 1995,
        age: getAge
    };
    
    xiaoming.age(); // 25
    getAge.apply(xiaoming, []); // 25, this指向xiaoming, 参数为空
    getAge.call(xiaoming);

    .

  • 相关阅读:
    SQL Server 2005 数据定义语言触发器(Data Definition Language Triggers)[翻译]
    sqlserver 存储过程例子
    微软CEO鲍尔默:科技产业终将成为经济救世主
    poj:2689用筛选法选素数求区间[L,U]的所有素数
    ZOJ Problem Set 1002 Fire Net
    去除多余括号
    模板元编程:求N的阶乘
    算法导论10.2习题
    奇数阶魔方算法
    TSQL 编程常用例子
  • 原文地址:https://www.cnblogs.com/xiangsj/p/12361249.html
Copyright © 2020-2023  润新知