const vs let when calling require

后端 未结 4 2037
盖世英雄少女心
盖世英雄少女心 2021-02-01 01:08

As io.js now supports ES6 you are finally able to use the const and let keywords. Obviously, let is the successor of var, jus

4条回答
  •  执念已碎
    2021-02-01 01:47

    Performance test const vs let usage on require for Node.js 6.10:

    require('do-you-even-bench')([
      { name: 'test 1', fn: function() { 
        const path = require('path');
        } 
      },
      { name: 'test 2', fn: function() { 
        let path = require('path');
        } 
      }
    ]);
    

    test 1 .... 2,547,746.72 op/s
    test 2 .... 2,570,044.33 op/s

提交回复
热议问题