Created
January 12, 2015 06:42
-
-
Save JustinChoi21/4046462c5e9584202c71 to your computer and use it in GitHub Desktop.
Javascript 유용한 코드 모음
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* break 와 return 활용 */ | |
// break는 for문을 종료 시킴 => console.log("end") 가 찍힘 | |
(function forBreakReturnTest() { | |
console.log("start"); | |
for (var inx = 0; inx < 10; inx ++) { | |
console.log(" inx : " + inx ); | |
if(inx == 5) { | |
break; | |
} | |
} | |
console.log("end"); | |
})(); | |
// return 은 함수 자체를 종료시킴 | |
// 그냥 return 하면 null이 리턴됨 | |
(function forBreakReturnTest() { | |
console.log("start"); | |
for (var inx = 0; inx < 10; inx ++) { | |
console.log(" inx : " + inx ); | |
if(inx == 5) { | |
return; | |
} | |
} | |
console.log("end"); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment