Blog Details

JavaScript Objects


                                
                                    <h2>* JavaScript Objects :-</h2>
<ul>
	<li>Almost everything in JavaScript can be an Object: Strings, Functions, Arrays, Dates....</li>
	<li>Objects are just data, with added properties and methods.</li>
</ul>
&nbsp;
<h2>* Properties and Methods :-</h2>
<ul>
	<li><strong>Properties</strong> are <strong>values</strong> associated with objects.</li>
	<li><strong>Methods</strong> are <strong>actions</strong> objects can perform.</li>
	<li><span style="font-size: 1.17em;"><strong>Object</strong> : car</span></li>
	<li><strong>Properties</strong>:</li>
</ul>
car.name = Fiat

car.model = 500

car.weight = 850kg

car.color = white
<ul>
	<li><strong>Methods</strong>:</li>
</ul>
car.start()

car.drive()

car.brake()

&nbsp;
<ul>
	<li>The <strong>properties</strong> of the car include name, model, weight, color, etc.</li>
	<li>All cars have these properties, but the property values differ from car to car.</li>
	<li>The <strong>methods</strong> of the car could be start(), drive(), brake(), etc.</li>
	<li>All cars have these methods, but they are performed at different times.</li>
</ul>
&nbsp;
<h2>Objects in JavaScript :-</h2>
<ul>
	<li>In JavaScript, objects are data (variables), with properties and methods.</li>
	<li>You create a JavaScript String object when you declare a string variable like this:</li>
	<li><strong> var txt = new String("Hello World");</strong></li>
</ul>
&nbsp;
<h2>Accessing Object Properties :-</h2>
<strong>syntax:</strong>
<ul>
	<li><strong><i>objectName.propertyName</i></strong></li>
</ul>
&nbsp;
<h3> <strong>example:</strong></h3>
<strong></strong>                  var message = "Hello World!";

var x = message.length;

var x = message.toUpperCase();

&nbsp;
<h3><strong>Output:</strong></h3>
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