Error type
SyntaxError
무ìì´ ì못 ëììê¹ì?
ì½ëìë ìµìí ë ê°ì ì¸ìê° ì ë¬ ë 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.")