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

The link in the given answer is broken. Here is a great plugin which I use daily and no issue so far:

Java Script Regions

PS: Not tried this with other than VS 2017

enter image description here


Select the code you want to compress. Press Ctrl + M + H. That code will now be collapsible. For readability, comment above the "region" to give it a name.

Source: http://blog.degree.no/2013/05/define-a-region-in-javascript-files-visual-studio-2010-2012/


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.