zoukankan      html  css  js  c++  java
  • ES6/5比较

     
    ES6
    function f (x, y, ...a) {
        return (x + y) * a.length
    }
    f(1, 2, "hello", true, 7) === 9
    
    ES5
    function f (x, y) {
        var a = Array.prototype.slice.call(arguments, 2);
        return (x + y) * a.length;
    };
    f(1, 2, "hello", true, 7) === 9;
    ECMAScript 6 
    class Shape {
        constructor (id, x, y) {
            this.id = id
            this.move(x, y)
        }
        move (x, y) {
            this.x = x
            this.y = y
        }
    }
    ECMAScript 5  
    var Shape = function (id, x, y) {
        this.id = id;
        this.move(x, y);
    };
    Shape.prototype.move = function (x, y) {
        this.x = x;
        this.y = y;
    };
    ECMAScript 6  
    class Rectangle extends Shape {
        constructor (id, x, y, width, height) {
            super(id, x, y)
            this.width  = width
            this.height = height
        }
    }
    class Circle extends Shape {
        constructor (id, x, y, radius) {
            super(id, x, y)
            this.radius = radius
        }
    }
    ECMAScript 5  
    var Rectangle = function (id, x, y, width, height) {
        Shape.call(this, id, x, y);
        this.width  = width;
        this.height = height;
    };
    Rectangle.prototype = Object.create(Shape.prototype);
    Rectangle.prototype.constructor = Rectangle;
    var Circle = function (id, x, y, radius) {
        Shape.call(this, id, x, y);
        this.radius = radius;
    };
    Circle.prototype = Object.create(Shape.prototype);
    Circle.prototype.constructor = Circle;
  • 相关阅读:
    数据泵导出 备份文件以日期时间命名
    执行计划的查看
    truncate 函数用法示例
    几个小知识点
    删除大表数据
    转 oracle 11g 导出空表
    数值转为财务大写
    oracle 取随机数据
    大表 update 方式
    >hibernate.cfg.xml的一些常用配置
  • 原文地址:https://www.cnblogs.com/douglasvegas/p/5899854.html
Copyright © 2011-2022 走看看