[size=medium]Technically speaking, the function statement is not a statement. Statements cause dynamic behavior in a
JavaScript program, while function definitions describe the static structure of a program. Statements are
executed at runtime, but functions are defined when JavaScript code is parsed, or compiled, before it is
actually run. When the JavaScript parser encounters a function definition, it parses and stores (without
executing) the statements that comprise the body of the function. Then it defines a property (in the call
object if the function definition is nested in another function; otherwise, in the global object) with the
same name as the function to hold the function.
The fact that function definitions occur at parse time rather than at runtime causes some surprising
effects. Consider the following code:
These unusual results occur because function definition occurs at a different time than variable definition.
Fortunately, these situations do not arise very often.[/size]
JavaScript program, while function definitions describe the static structure of a program. Statements are
executed at runtime, but functions are defined when JavaScript code is parsed, or compiled, before it is
actually run. When the JavaScript parser encounters a function definition, it parses and stores (without
executing) the statements that comprise the body of the function. Then it defines a property (in the call
object if the function definition is nested in another function; otherwise, in the global object) with the
same name as the function to hold the function.
The fact that function definitions occur at parse time rather than at runtime causes some surprising
effects. Consider the following code:
alert(f(4)); // Displays 16. f( ) can be called before it is defined. var f = 0; // This statement overwrites the property f. function f(x) { // This "statement" defines the function f before either return x*x; // of the lines above are executed. } alert(f); // Displays 0. f( ) has been overwritten by the variable f.
These unusual results occur because function definition occurs at a different time than variable definition.
Fortunately, these situations do not arise very often.[/size]
发表评论
-
Extending Built-in Types
2009-01-08 13:55 729The Function.apply( ) method is ... -
Breakpoints using closures
2009-01-07 13:43 872// // This function implements ... -
Private properties with closures
2009-01-07 13:13 769// // This function adds proper ... -
Constructor Functions
2009-01-07 00:42 764the new operator creates a new ... -
Functions as Methods
2009-01-07 00:39 810When a function is invoked as a ... -
The callee Property
2009-01-07 00:02 668In addition to its array elemen ... -
Variable-Length Argument Lists: The Arguments Obje
2009-01-06 23:06 794The Arguments object has one ve ... -
Function Literals
2009-01-06 21:50 705Although function literals crea ... -
Nested Functions
2009-01-06 21:09 770Nested functions may be defined ... -
Deleting Array Elements
2009-01-05 22:11 573The delete operator sets an arr ... -
Reading and Writing Array Elements
2009-01-05 22:00 775Note that array indexes must be ... -
The valueOf() Method
2009-01-05 18:05 748... -
The toLocaleString() Method
2009-01-05 18:02 859In ECMAScript v3 and JavaScript ... -
The constructor Property
2009-01-05 17:51 794[size=medium]Since constructor ... -
the empty statement
2009-01-05 00:29 789[size=medium]When you intention ... -
with
2009-01-05 00:27 687[size=medium]The with statement ... -
try/catch/finnaly
2009-01-05 00:17 895If control leaves the try bloc ... -
throw
2009-01-04 23:56 698The tHRow statement has the fol ... -
return
2009-01-04 23:52 820If a function executes a return ... -
Labels
2009-01-04 23:01 712Label names are distinct from v ...
相关推荐
In 1954, a conference on mathematical tables, sponsored by M.I.T. and the National Science Foundation, met to discuss a modernization and extension of Jahnke and Emde's classical tables of functions....
fashioned and cumbersome query approaches and answer your business intelligence questions through simple and powerful queries built on common table expressions (CTEs) and window functions. These new ...
在优化算法领域,benchmark functions是评估和比较不同算法性能的重要工具。这些函数通常是设计成具有各种挑战性特性的,如多模态、非线性、非凸性等,以模拟实际问题中的复杂优化场景。Benchmark functions.zip ...
1. 手册名称与内容:该文档是一本名为《Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables》的手册,它包含了数学公式的列表、相关函数的图像以及数学表格。 2. 编辑和出版信息...
在本文中,我们将深入探讨如何使用Visual Studio 2017来创建和管理Azure Functions,这是一个基于事件驱动的计算服务,允许开发者构建无服务器应用程序。Azure Functions让你可以在需要时运行代码,而无需预置或管理...
**描述分析:** "memcache与mysql结合必备" 表明Memcached Functions for MySQL是实现这两个技术协同工作的一个关键组件。Memcache是一个内存对象缓存系统,用于存储和检索数据,而MySQL则是一种关系型数据库管理...
Expert T-SQL Window Functions in SQL Server takes you from any level of knowledge of windowing functions and turns you into an expert who can use these powerful functions to solve many T-SQL queries....
1.2 Matrix-Monotone Functions 3 1.3 Classification and Organization 4 1.4 Notation 7 2 Majorization Theory 9 2.1 Definition and Examples 10 2.2 Basic Results 18 2.3 Majorization and Optimization 30 3 ...
本文将深入探讨“Get_Functions_details”这个主题,它涉及几种智能优化算法的测试函数,以及如何通过这些函数评估算法的性能。 智能优化算法是一类模仿自然界生物进化或物理现象的计算方法,它们能够在多维度的...
### 高清彩版《学习Azure Functions》知识点详解 #### 一、书籍基本信息与版权说明 - **书名**:《学习Azure Functions》 - **作者**:Manisha Yadav, Mitesh Soni - **出版社**:Packt Publishing - **出版日期**...
Topological Spaces: Including a Treatment of Multi-Valued Functions, Vector Spaces and Convexity Topological Spaces: Including a Treatment of Multi-Valued Functions, Vector Spaces and Convexity ...
LabSQL ADO Functions是LabVIEW中用于操作数据库的一系列功能,这些功能允许用户通过ActiveX Data Objects(ADO)技术与各种数据库系统进行交互。ADO是一种强大的接口,它封装了多种数据库访问技术,如OLE DB和ODBC...
《初识Azure Functions》 Azure Functions是微软云平台Azure中的一个无服务器计算服务,它允许开发者编写一次性定义、按需执行的代码片段,无需预先配置或管理任何基础设施。本资源主要针对初学者,旨在深入浅出地...
# IAR C Library Functions Reference Guide 知识点详解 ## IAR C Library Functions 概述 ### 标题解析: **IAR C LIBRARY FUNCTIONS Reference Guide**:此标题明确指出文档是关于IAR C库函数的参考指南。IAR C ...
数学函数手册(Handbook of Mathematical Functions)是一本经典的数学参考书籍,由Milton Abramowitz和Irene A. Stegun编著。这本书最初由美国政府委托编写,也是数学领域里引用率非常高的一本书籍。它最初于1964年...
INTEGRALS AND SERIES VOLUME 2 SPECIAL FUNCTIONS
由于提供的文件内容包含了大量版权和商标声明,并没有提供实际的Teradata SQL Functions, Operators, Expressions和Predicates的相关知识内容,因此无法直接从文件内容中生成具体的知识点。不过,我可以根据文件的...
《MATLAB Functions for Mie Scattering and Absorption Version 2》是专为研究光学领域中的Mie散射和吸收现象而设计的一套MATLAB函数集。这套工具包由Christoph Maetzler开发,旨在帮助科学家和工程师计算粒子在...
《PyPI 官网下载 | iglovikov_helper_functions-0.0.36.tar.gz 知识点详解》 PyPI(Python Package Index)是Python开发者的重要资源库,它为全球的Python开发者提供了一个集中发布和下载Python软件包的平台。在...