Message
SyntaxError: malformed formal parameter (Firefox)
Error type
무μμ΄ μλͺ» λμμκΉμ?
μ½λμλ μ΅μν λ κ°μ μΈμκ° μ λ¬ λ Function()
μμ±μκ° μμ΅λλ€. λ§μ§λ§ μΈμλ μμ±μ€μΈ μ ν¨μμ μμ€μ½λ μ
λλ€. λλ¨Έμ§λ λͺ¨λ μ ν¨μμ μΈμ λͺ©λ‘μ ꡬμ±ν©λλ€.
μΈμ λͺ©λ‘μ΄ μ΄λκ° μλͺ»λμμ΅λλ€. μλ§λ μ€μλ‘ μΈμ μ΄λ¦μΌλ‘ if λλ varμ κ°μ ν€μλλ₯Ό μ ννκ±°λ μΈμ λͺ©λ‘μ κ°κ³³ μμ ꡬλμ μ΄ μμ μ μμ΅λλ€. λλ μ€μλ‘ μ«μλ κ°μ²΄μ κ°μ μλͺ»λ κ°μ μ λ¬ν κ²μΌ μ μμ΅λλ€.
κ·Έλ, λ΄ λ¬Έμ κ° ν΄κ²°λμ΄. κ·Όλ° μ λ§ μν΄μ€¬μ΄?
νλ¦Ό μμ΄ μ€λ₯ λ©μΈμ§μ ννμ λ€μ μ΄μν λΆλΆμ΄ μμ΅λλ€. "곡μ λ§€κ° λ³μ"λ "ν¨μ μΈμ"λ₯Ό λ§νλ μ’μ λ°©λ²μ λλ€. μ°λ¦¬λ "μλͺ»λ νμμ λ¨μ΄λ₯Ό μ¬μ©νλ€"λΌκ³ νν ν©λλ€.
Examples
Invalid cases
var f = Function('x y', 'return x + y;');
// SyntaxError (missing a comma)
var f = Function('x,', 'return x;');
// SyntaxError (extraneous comma)
var f = Function(37, "alert('OK')");
// SyntaxError (numbers can't be argument names)
Valid cases
var f = Function('x, y', 'return x + y;'); // correctly punctuated
var f = Function('x', 'return x;');
// if you can, avoid using Function - this is much faster
var f = function(x) { return x; };
See also
Function()
- About functions
- Frankenstein by Mary Wollstonecraft Shelley, full e-text ("Cursed (although I curse myself) be the hands that formed you! You have made me wretched beyond expression. You have left me no power to consider whether I am just to you or not. Begone! Relieve me from the sight of your detested form.")