Javascript Objects

 

Javascript Objects :-

An Objects is an un-arranged set of properties that may be accessed using dot [ . ] Operator.

Example of Object :-

Object.property

Object[“property”]

Example : men with running Property

Men.run();

 

Object are created using the new Keyword using constructor.

Function men(name){

this.name=name;

this.run=run;

this.eat=function () { alrt(“pizza”);}

Note :- this Statement refers to the current Object.

Object with Array :-

Use of array Constructor

Var   a =new Array ( element1 , element 2, element3, ………………………….);

JavaScript use zero Indexing

a[0]=”welcome in tutorialworld”;

Use of Alert  with Array indexing

alert(a[2]);

Length Function with array

alert  (a.length);

Function with new keyword :

a.sort(new Function(“name”, “alert(“hello”+name)”));




Follow Us

Contact Us

tutorialworldin@yahoo.com

Back to Top