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# and are asking for this in their JavaScript file. Any suggestions? I am using Visual Studio 2017 and Team Foundation Server.
Javascript has a reasonably C-like syntax, and it's a very popular language. Javascript has a lot of quirks, but it has one powerful similarity to C - it's simple.
The best alternative is Java. It's not free, so if you're looking for a free alternative, you could try C++ or Rust. Other great apps like C (programming language) are Go (Programming Language), C#, Lua and Perl.
These languages are C++ (also known as C with classes), C#, Python, Java, JavaScript, Perl, PHP, Verilog, D, Limbo and C shell of Unix etc. Every language uses C language in variable capacity.
C++ is a superset of C, so both languages have similar syntax, code structure, and compilation. Almost all of C's keywords and operators are used in C++ and do the same thing. C and C++ both use the top-down execution flow and allow procedural and functional programming.
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.
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
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With