{"json_modified": "2014-04-02T17:13:17.904462", "slug": "Web/JavaScript/Reference/Functions_and_function_scope", "tags": ["Guide", "NeedsHelp", "JavaScript"], "locale": "en-US", "title": "Functions and function scope", "translations": [{"locale": "es", "url": "/es/docs/Referencia_de_JavaScript_1.5/Funciones", "last_edit": "2007-06-03T17:23:03", "title": "Funciones"}, {"locale": "fr", "url": "/fr/docs/R%C3%A9f%C3%A9rence_de_JavaScript_1.5_Core/Fonctions_et_portee_des_fonctions", "last_edit": "2013-07-18T05:30:02", "title": "Fonctions et port\u00e9e des fonctions"}, {"locale": "it", "url": "/it/docs/Web/JavaScript/Reference/Functions_and_function_scope", "last_edit": "2014-03-14T02:58:52", "title": "Functions and function scope"}, {"locale": "ja", "url": "/ja/docs/Web/JavaScript/Reference/Functions_and_function_scope", "last_edit": "2013-09-17T05:46:20", "title": "\u95a2\u6570\u3068\u95a2\u6570\u30b9\u30b3\u30fc\u30d7"}, {"locale": "ru", "url": "/ru/docs/%D0%AF%D0%B4%D1%80%D0%BE_JavaScript_1.5_%D0%A1%D0%BF%D1%80%D0%BE%D0%B2%D1%87%D0%BD%D0%B8%D0%BA/Functions", "last_edit": "2011-10-02T19:33:51", "title": "Functions"}, {"locale": "zh-CN", "url": "/zh-CN/docs/JavaScript/Reference/Functions_and_function_scope", "last_edit": "2013-02-09T08:47:50", "title": "\u51fd\u6570\u548c\u51fd\u6570\u4f5c\u7528\u57df"}], "modified": "2014-04-02T17:13:17", "label": "Functions and function scope", "url": "/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope", "last_edit": "2014-04-02T17:13:15", "summary": "Generally speaking, a function is a \"subprogram\" that can be <em>called</em> by code external (or internal in the case of recursion) to the function. Like the program itself, a function is composed of a sequence of statements called the <em>function body</em>. Values can be <em>passed</em> to a function, and the function can <em>return</em> a value.", "sections": [{"id": "Summary", "title": "Summary"}, {"id": "General", "title": "General"}, {"id": "Defining_functions", "title": "Defining functions"}, {"id": "The_function_declaration_.28function_statement.29", "title": "The function declaration ( function statement)"}, {"id": "The_function_expression_.28function_operator.29", "title": "The function expression ( function operator)"}, {"id": "The_arrow_function_expression_(.3D>)", "title": "The arrow function expression (=>)"}, {"id": "The_Function_constructor", "title": "The Function constructor"}, {"id": "The_arguments_object", "title": "The arguments object"}, {"id": "Scope_and_the_function_stack", "title": "Scope and the function stack"}, {"id": "Recursion", "title": "Recursion"}, {"id": "Nested_functions_and_closures", "title": "Nested functions and closures"}, {"id": "Efficiency_considerations", "title": "Preservation of variables"}, {"id": "Multiply-nested_functions", "title": "Multiply-nested functions"}, {"id": "Name_conflicts", "title": "Name conflicts"}, {"id": "Function_constructor_vs._function_declaration_vs._function_expression", "title": "Function constructor vs. function declaration vs. function expression"}, {"id": "Conditionally_defining_a_function", "title": "Conditionally defining a function"}, {"id": "Functions_as_event_handlers", "title": "Functions as event handlers"}, {"id": "Local_variables_within_functions", "title": "Local variables within functions"}, {"id": "Examples", "title": "Examples"}, {"id": "Example:_Returning_a_formatted_number", "title": "Example: Returning a formatted number"}, {"id": "Example:_Determining_whether_a_function_exists", "title": "Example: Determining whether a function exists"}, {"id": "See_also", "title": "See also"}], "id": 777, "review_tags": ["editorial"]}