WebArtz - The Web Design Forum
Welcome to WebArtz, Guest!

WebArtz is a nice place for discussions related to web designing and coding. We help our members to code their own website templates with HTML and CSS. We give them advice on various issues.

To know more about WebArtz Forum, visit the About Us page.

At the moment, you are viewing the forum as a guest. As a guest you can't make post and participate in discussions. You need to register and become a member of the forum. Click the register link below and become a part of this forum.

Thank You

WebArtz - The Web Design Forum
Welcome to WebArtz, Guest!

WebArtz is a nice place for discussions related to web designing and coding. We help our members to code their own website templates with HTML and CSS. We give them advice on various issues.

To know more about WebArtz Forum, visit the About Us page.

At the moment, you are viewing the forum as a guest. As a guest you can't make post and participate in discussions. You need to register and become a member of the forum. Click the register link below and become a part of this forum.

Thank You


You are not connected. Please login or register

View previous topic View next topic Go down  Message [Page 1 of 1]

1Accespted Objects Wed Mar 09, 2011 7:09 pm

Unknown Data

Unknown Data
Registered Member
Registered Member
Variables
Learn JavaScript - Part 4


I mentioned earlier that JS is an objectoriented programminglanguage. And the concept "object" will I try to define in this lesson.

Objects is a variable type, that can handle multiple values and functions at the same time. If we take a look at the syntax, can it look like this.
Code:
objectname.method()
The concept object
The easiest way to explain objects, is by calling them a thing - like a car. But a car isn't just a car, there are many types of cars, versions etc.
It's actually the same in JavaScript. JS sees objects as elements in a browser. That could fx. be elements in a form, or a new browser window.

Properties
The properties is what objects got. As an example has a car wheels, and that's the property in this context.
And again is it the same, when we're talking about JS. A browser window got a title, and therefore is the title the property. Another property could be the status bar.

Note: The cars wheels is also an object in itself, and not just a property. So an object can also contains objects.

Methods
Methods is what our object can do, and in our example can the car drive. In JS can we as an example click on a button; click() or open a window open().
So methods is explained by what someone can do or what there can happen, fx. dance, write, walk, burn. In other words, can we best compare methods with verbs.

If we as an example take the phrase from our Hello World script, will the brackets indicate that there is a reference to the method, and not the property.

Merging it
These 3 elements can we now put together and form a bether description of our object. The individual elements is separated by a dot. So it will look like this now.
Code:
car.wheel()
document.write()

As mentioned earlier can an object contain an object. Are we using the object document, then can it contain the property location, that's inself is also an object. But the location object contains the property href, which creates:
document.location.href

Note: It's always a good idea to give an object an uniquely name, don't use names like window1, window2 etc.

In the next lesson will we learn about the functions.

Notice : This tutorial is copyrighted by WebArtz Forum. You may not publish it on anywhere without written permission from the administrators.

http://woops.dk

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum