Clean way to keep original variable and destruction at the same time

前端 未结 3 858
轮回少年
轮回少年 2020-12-03 17:36

Is there a cleaner way to do this (with anything that is at least an ES draft and has a babel plugin, i.e., ES6, ES7, etc.):

const { a, b } = result = doSome         


        
3条回答
  •  Happy的楠姐
    2020-12-03 18:29

    One possible way:

    const result = doSomething(), 
        { a, b } = result;
    

    You still have to duplicate the name, though. const token isn't quite right-handy. )

提交回复
热议问题