Blog Details

JavaScript Objects



                                

* JavaScript Objects :-

  • Almost everything in JavaScript can be an Object: Strings, Functions, Arrays, Dates....
  • Objects are just data, with added properties and methods.
 

* Properties and Methods :-

  • Properties are values associated with objects.
  • Methods are actions objects can perform.
  • Object : car
  • Properties:
car.name = Fiat car.model = 500 car.weight = 850kg car.color = white
  • Methods:
car.start() car.drive() car.brake()  
  • The properties of the car include name, model, weight, color, etc.
  • All cars have these properties, but the property values differ from car to car.
  • The methods of the car could be start(), drive(), brake(), etc.
  • All cars have these methods, but they are performed at different times.
 

Objects in JavaScript :-

  • In JavaScript, objects are data (variables), with properties and methods.
  • You create a JavaScript String object when you declare a string variable like this:
  •  var txt = new String("Hello World");
 

Accessing Object Properties :-

syntax:
  • objectName.propertyName
 

 example:

                  var message = "Hello World!"; var x = message.length; var x = message.toUpperCase();  

Output:

12 HELLO WORLD!


Categories

Javascript

Latest posts

13.05.14
Implementing CRUD Operations ¶

<ul> <li>Now comes the fun part. We would like t

13.05.14
View

<ol> <li><a href="http://www.yiiframework.com/do

13.05.14
Creating Model

<ol> <li><a href="http://www.yiiframework.com/do

Get Free Quote