Functions Are Objects of the "Function" Type
Treating functions as objects can lead to several programming implications:
- A function can be created with the Function() constructor.
- A function has inherited properties and methods: length, apply(), call(), and toString().
- A function can have its own instance properties - nice way to share values across multiple function calls.
- A function can be created as part of an expression.
- A function can be passed as a parameter into other functions.
A function can be created in 3 different ways:
- Using the "function" declaration statement - Creating a function in the traditional way.
- Using the "function" operator - Creating a function as a function literal on the fly while evaluating an expression.
- Using the "Function()" constructor Creating a function in the object-oriented way.
Table of Contents
About This Book
Data Types, Variables and Expressions
Flow Control Statements
Creating, Accessing, and Manipulating Arrays
Defining and Calling Functions
Server-Side and Client-Side Web Scripting
Introduction to Objects
Defining Your Own Object Types
Inheritance of Properties and Methods through the Prototype Object Chain
►Using Functions as "Function" Objects
►Functions Are Objects of the "Function" Type
Using the Function Constructor
Function Object Inherited Properties and Methods
Function Object Instance Properties
Creating Function Objects with "function" Statements
Creating Function Objects with the "function" Operator
Comparing 3 Ways of Creating Functions
Introduction to Built-in Object Types
W3C's Document Object Model (DOM) Specifications
PDF Printing Version