最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin2浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论