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

后端 未结 5 2064
生来不讨喜
生来不讨喜 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:30

    a Lot of people have already answered on how to get this in Visual studio I will however suggest a different approach. Since #region is a tag limited to visual studio, it will mostly not be detected by other editors.

    But in most other editors, they do however recognize "if" and "while" conditions. You can use if (1) and While(1) to create blocks of collapsible code that can be folded.

    for eg

    // This is a comment for the code block below
    if(1){
    ....
    ...
    }
    

    you will get a -/+ sign next to this code block in many others editors (Unless you are using basic notepad)

提交回复
热议问题