Ad
Code
Diff
  • class Component {
      constructor(dom) {
        console.log('Parent class constructor executed!');
        this.dom = dom;
      }
      
      onCreate() {
        return true;
      }
    }
    
    class Collection extends Component {
        constructor(dom,flag){
          super(dom);
          this.flag=flag;
        }
      // 
    }
    • class Component {
    • constructor(dom) {
    • console.log('Parent class constructor executed!');
    • this.dom = dom;
    • }
    • onCreate() {
    • return true;
    • }
    • }
    • class Collection {
    • class Collection extends Component {
    • constructor(dom,flag){
    • super(dom);
    • this.flag=flag;
    • }
    • //
    • }
Code
Diff
  • class Component {
      constructor(dom){
        this.dom = dom;
      }
      
      onCreate() {
        return this.dom;
      }
    }
    
    const comp = new Component();
    comp.onCreate();
    • function Component(dom) {
    • this.dom = dom;
    • this.onCreate = function() {
    • class Component {
    • constructor(dom){
    • this.dom = dom;
    • }
    • onCreate() {
    • return this.dom;
    • }
    • }
    • }
    • const comp = new Component();
    • comp.onCreate();
Code
Diff
  • function todo() {
      return 'Walk';
    }
    
    // reescrever em ES6
    (() => {
    
      function todo() {
        return 'Run';
      }
    
    })();
    
    • function todo() {
    • return 'Walk';
    • }
    • // reescrever em ES6
    • (function() {
    • (() => {
    • function todo() {
    • return 'Run';
    • }
    • })();
Code
Diff
  • var bg = 'gray';
    
    var css = `<style>
        body {
          background: ${bg}
          color: black;
        }
      </style>`;
      
    
    • var bg = 'gray';
    • var css = '' +
    • '<style>' +
    • 'body {' +
    • ' background: '+ bg + ';' +
    • ' color: black;'
    • '}' +
    • '</style>';
    • var css = `<style>
    • body {
    • background: ${bg}
    • color: black;
    • }
    • </style>`;
Code
Diff
  • // reescreva em ES6
    function main(a, b=2, c=3) {
            
        return a * b * c;
    }
    • // reescreva em ES6
    • function main(a, b, c) {
    • if (typeof b == 'undefined')
    • b = 2;
    • if (typeof c == 'undefined')
    • c = 3
    • function main(a, b=2, c=3) {
    • return a * b * c;
    • }