Jump to content

Looking for a little clarification


lilman

Recommended Posts

When looking at JavaScript code I am having a tough time distinguishing Objects, Properties and Methods. Objects I am getting the hang of, but it is Properties and Methods that is a tad confusing.

I hope someone can help me out and explain how you can distinguishing them apart.
Link to comment
Share on other sites

here is an example of an object with methods and properties

[code]
var example = { // object
ex: true,  // property

meth: function(){
if(example.ex == true){
alert(example.ex);
}else{
alert('False');
}
} //method
}
[/code]

and to call i the method you'd do

example.meth();  //alerts true

and of course you can have an object without methods

var obj = {eyes: 'brown', hair: 'black', height: '6\'0'}
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.