The first useful technique is to put a brief
comment after each closing brace so you know what it pertains to:
function MySomething () {
if ((x=1) || (y-2)) {
for (var i=0; i<10; i++) {
if (a>b) {
DoAnotherSomething()
}
else {
switch (important) {
true: thing()
false: otherthing()
} // switch important
} //else
} // for i
} // if
} // function MySomthing
It doesn't do anything to help the computer, but it does heaps to help you.
Here's the secret: the time to add these comments is when you're first writing the code.
When you open a curly bracket, before you add the contents, first add the closing curly bracket with a comment so you know what it matches up with.