JavaScript define and return a variable on one line

前端 未结 3 706
轻奢々
轻奢々 2021-01-25 03:19

In JavaScript, if I want to return a variable but don\'t want to modify it or leak it into the global scope, can I define and return it on one line like this?

re         


        
3条回答
  •  有刺的猬
    2021-01-25 03:56

    I cannot see why you would want to do that since once you return you are out of scope.

    Just do

    return 'bar';
    

提交回复
热议问题