Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

the : in javascript/json

Status
Not open for further replies.

NuJoizey

MIS
Aug 16, 2006
450
US
i've got a function that looks like this, but I really only have a vague understanding what it's doing. I think that it is JSON, but can somebody either explain to me what is happening in javascript formatted like this or point me towards a useful tutorial that I can read - i've read some similar things on the web, but nothing that seems to address this specific syntax:

Code:
   name: function(doSomething, e) {
        if (condition) {
            doStuff();
        }
        
    },

What does the colon after name denote, and why is there a comma at the end?

Thanks for considering my question.

Uncommitted, except to looking good. Constantly judging.
Always on the verge of being upset.
 
that looks like json, at least part of json. wikipedia is a good primer ( here is another example
Code:
var me = {
  displayInfo: function(){
    alert(this.firstName + "(" + this.age +")");
  },
  firstName: "jason"
};
me.age = 30;
me.displayInfo();
[tt]{}[/tt] creates an object. we assign that object to [tt]me[/tt]. we create the object with 2 members. [tt]displayInfo[/tt] and [tt]firstName[/tt]. because js is dynamic we add another member, [tt]age[/tt], later (next line). finally we call [tt]displayInfo()[/tt] which shows a message box with the members we defined.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top