JS — exit the function — return
1 min readSep 5, 2018
함수빠져나오기
The return statement ends function execution
let countTo = function(num){
if(typeof num != 'number') return false;
for(var i = 1; i <= num; i++){
console.log(i);
}
}
//countTo(9) // number
//console.log(countTo('9')) //string - false
- examine other’s code
function revealImage(element) {
// If the watcher isn't in the viewport exit the function
if(!this.isInViewport) {
return;
}....}
#reference
#add 13.09.2018
if(!audio) return; // if other keys are down, exits this function.
console.log(audio)
audio.play();