Category: Functions and Objects

Functions and Objects

PHP header() Function

PHP header() Function

The header() function sends a raw HTTP header to a client.   It is important to notice that header() must be called before any actual output is sent. Syntax Parameter Description string Required. Specifies...

The prototype Keyword

The prototype Keyword

The prototype keyword can save you a lot of memory. In the User class, every instance will contain the three properties and the method. Therefore, if you have 1,000 of these objects in memory,...

Accessing Objects

Accessing Objects

To access an object, you can refer to its properties, as in the following two unrelated example statements: So to access the showUser method of an object of class User, you would use the...

Creating an Object

Creating an Object

To create an instance of the class User, you can use a statement such as the following: Or you can create an empty object, like this: and then populate it later, like this: You...

JavaScript Objects

JavaScript Objects

A JavaScript object is a step up from a variable, which can contain only one value at a time, in that objects can contain multiple values and even functions. An object groups data together...

Returning a Value

Returning a Value

Functions are not used just to display things. In fact, they are mostly used to perform calculations or data manipulation and then return a result. The function fixNames in following Example uses the arguments...

JavaScript Functions

JavaScript Functions

In addition to having access to dozens of built-in functions (or methods) such as write, which you have already seen being used in document.write, you can easily create your own functions. Whenever you have...