Statement

μžλ°”μŠ€ν¬λ¦½νŠΈμ—μ„œ λ¬Έ(Statement)은 λ¬Έμž₯(Sentence), ν‘œν˜„μ‹(Expression)은 어ꡬ(Phase), μ—°μ‚°μžλŠ” ꡬ두점/접속사에 해당됨

var a = 3 * 6;
var b = a;
b;

μ—¬κΈ°μ„œ 각각은 ν‘œν˜„μ‹μ΄μž ν‘œν˜„μ‹μ΄ ν¬ν•¨λœ 문이닀

문의 μ™„λ£Œ κ°’

λͺ¨λ“  문은 μ™„λ£Œ 값을 κ°€μ§„λ‹€. μ˜ˆμ»¨λŒ€, λ³΄ν†΅μ˜ { } 블둝은 λ‚΄λΆ€μ˜ κ°€μž₯ λ§ˆμ§€λ§‰ λ¬Έ/ν‘œν˜„μ‹μ˜ μ™„λ£Œ 값을 μžμ‹ μ˜ μ™„λ£Œ κ°’μœΌλ‘œ λ°˜ν™˜ν•œλ‹€

var b;

if (true) {
    b = 4 + 38;
}

// λΈŒλΌμš°μ € μ½˜μ†” μ°½μ—μ„œ μ‹€ν–‰ν•˜λ©΄ 42κ°€ λ‚˜μ˜¨λ‹€

ν‘œν˜„μ‹μ˜ λΆ€μˆ˜ 효과

function vowels(str) {
    if (str) {
        matches = str.match(/[aeiou]/g]);

        if (matches) {
            return matches;
        }
    }
}

vowels("Hello World"); // ["e", "o", "o"]

λ§Žμ€ μ‚¬λžŒμ΄ λ¬Έμžμ—΄μ—μ„œ λͺ¨μŒμ„ μΆ”μΆœν•˜λŠ” μ½”λ“œλ₯Ό μœ„μ™€ 같이 μž‘μ„±ν•˜μ§€λ§Œ, ν• λ‹Ή μ—°μ‚°μžμ˜ λΆ€μˆ˜ 효과λ₯Ό 잘 ν™œμš©ν•˜λ©΄ λ‹€μŒκ³Ό 같이 2개의 if 문을 ν•˜λ‚˜λ‘œ ν•©μΉ  수 μžˆλ‹€

function vowels(str) {
    var matches;

    if (str && (matches = str.match(/[aeiou]/g))) {
     return matches;   
    }
}

vowels("Hello World"); // ["e", "o", "o"]

Last updated

Was this helpful?