Is there anything in JavaScript or Visual Studio to detect if the code is used in debug-mode? Something like "#if DEBUG" in C#, but for JavaScript?
No.
#if
/#endif
are preprocessor directives in C# (and other languages) that tells the compiler to conditionally include/exclude a section of code when compiling.
JavaScript is a script language that is not precompiled, and therefore it would not make much sense to have preprocessor directives like these.