Skip to content

Instantly share code, notes, and snippets.

@cycold
Created August 7, 2014 03:57
Show Gist options
  • Save cycold/2136116c81af615e3f65 to your computer and use it in GitHub Desktop.
Save cycold/2136116c81af615e3f65 to your computer and use it in GitHub Desktop.
For 循环中的if中return语句
for( var i=0; i<10; i++ ){
if( i == 5 ){
console.log(i);
return i; //这里return后,后面的代码就不会执行了,即使是在if语句中
}
console.log(i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment