Is there something similar to C# regions in JavaScript? Visual Studio 2017

后端 未结 5 2079
生来不讨喜
生来不讨喜 2021-02-09 09:02

I am doing work for somebody who would like their JavaScript library organized into categories: CRUD functions, Form functions, etc. They really like the utility of regions in C

5条回答
  •  一个人的身影
    2021-02-09 09:31

    For VS 2019, Microsoft has fully implemented regions for Javascript, they work exactly they way they work in C#, only, you have to preface the beginning and end of the regions as comments, for example:

    //#region My Region
    function foo(){
      *//code*
    }
    //#endregion
    

    For anything prior to VS 2019, See Michael Drum's answer. His shortcut also works in VS 2019.

提交回复
热议问题