Thursday, February 25, 2016

Use return instead of exit in Javascript





In PHP, we use exit function to exit a loop.  We should not use exit in Javascrip.
The following  statement in JS is wrong
        if(fromTUG_id==null || fromTUG_id==undefined ||fromTUG_id==0) {
         exit;
          }

We should use return instead:
        if(fromTUG_id==null || fromTUG_id==undefined ||fromTUG_id==0) {
         return;          

       }

No comments:

Post a Comment