Standard conventions for indicating a function argument is unused in JavaScript

前端 未结 5 971
失恋的感觉
失恋的感觉 2020-11-28 14:19

Are there any standard ways of marking a function argument as unused in JavaScript, analogous to starting a method argument with an underscore in Ruby?

5条回答
  •  天涯浪人
    2020-11-28 14:38

    I would recommend this syntax:

    function(_index, value) {...}
    

    to not to shadow lodash variable and still have description of argument in case if it will be used.

    VS Code is also highlight these names properly and these unused args won't be deleted after autofix code smells

提交回复
热议问题