javascript - Will let keyword work on ES5? - Stack Overflow

What will be the output of the following code in ES5 piler? Will it throw any error or will it work fin

What will be the output of the following code in ES5 piler? Will it throw any error or will it work fine?

let foo = 123;
let {x,y} = getValues();

What will be the output of the following code in ES5 piler? Will it throw any error or will it work fine?

let foo = 123;
let {x,y} = getValues();
Share Improve this question edited Aug 7, 2018 at 13:45 Saswata Arabinda asked Aug 7, 2018 at 13:43 Saswata ArabindaSaswata Arabinda 5772 gold badges8 silver badges17 bronze badges 6
  • 5 Have you checked it? – hsz Commented Aug 7, 2018 at 13:43
  • While many implementations use jit (which still is not a static pile), javascript is in it's foundations an interpreted language, there is nothing like an "ES5 piler". – ASDFGerte Commented Aug 7, 2018 at 13:52
  • 1 @ASDF ECMAScript is just a language. A particular implementation of it may be piled or interpreted. – deceze Commented Aug 7, 2018 at 14:23
  • @deceze True. I was mainly concerned, that OP assumed the default action for javascript was pilation, but did wrong wording of "doesn't exist" vs "is absolutely not the standard action". Wikipedia has a good wording with "most of its implementations execute instructions directly and freely, without previously piling" – ASDFGerte Commented Aug 7, 2018 at 14:35
  • @ASDF Even that is… debatable. Any code needs to be piled in some form or another. The CPU doesn't execute plain JS after all. The distinction is usually how much the piler does and how much time it spends doing it. Something like C goes through a whole many steps of processing and optimisation, while "interpreted" usually mostly means that a lot of the optimisation and static analysis steps are skipped. However, modern JS engines will do quite expensive optimisation sometimes in parallel on the fly. – deceze Commented Aug 7, 2018 at 14:38
 |  Show 1 more ment

2 Answers 2

Reset to default 7

Will not work. let was introduced in ES6.

It wouldn't work for an ES5 piler. But using Babel will solve this issue by transpiling your ES6 code down to patible versions.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745408118a4626406.html

相关推荐

  • javascript - Will let keyword work on ES5? - Stack Overflow

    What will be the output of the following code in ES5 piler? Will it throw any error or will it work fin

    17小时前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信