How to format embedded if statements in JavaScript What would be the best way to format this code? It looks a bit messy to me in regards to indentation etc.

 if (typeof _srwc != 'undefined') {
    for (var i=0; i &lt; _srwc.length; i++){
         var currentArg = _srwc[i];;        
          if (typeof window[currentArg[0]] == 'function') {
             window[currentArg[0]](currentArg[1], currentArg[2], currentArg[3]);
             } else {
             console.log('The Setter method: "' + currentArg[0] + '" is undefined');
             }
    }
 }
How to format code is not really how CodeReview works ;)


You are indenting with 2 and with 4 spaces, pick one, I advocate 2
It is more common to compare _srwc to undefined itself
_srwc is an unfortunate name, it conveys no meaning
window[currentArg[0]](currentArg[1], currentArg[2], currentArg[3]); could use a comment block
Do not use console.log in production code
Also, read about apply, it allows you to call a function and pass an array of arguments so you don't have to be limited to 3 arguments.

if (_srwc !== undefined) {
  for (var i=0; i &lt; _srwc.length; i++){
    var currentArg = _srwc[i];
    if (typeof window[currentArg[0]] == 'function') {
      window[currentArg[0]](currentArg[1], currentArg[2], currentArg[3]);
    } else {
      console.log('The Setter method: "' + currentArg[0] + '" is undefined');
    }
  }
}