aspnetguy Posted November 23, 2006 Share Posted November 23, 2006 I've been looking at some libraries lately (mainly dojo) and have a few questions I hope someone can answer.Firstly what does this mean? var dojo = {}; I have seen var arr = []; used to define an array but not {}.Also I can't seem to understand what this is doing or what it means dojo.version = { // summary: version number of this instance of dojo. major: 0, minor: 4, patch: 0, flag: "", revision: Number("$Rev: 6258 $".match(/[0-9]+/)[0]), toString: function(){ with(dojo.version){ return major + "." + minor + "." + patch + flag + " (" + revision + ")"; // String } }} What is with the major: 0, minor: 0, etc and again there is the dojo.version = {...}, I assume the variable: value and {} are related but am not sure how.thanks Link to comment Share on other sites More sharing options...
aalbetski Posted November 23, 2006 Share Posted November 23, 2006 this is the shortcut for creating a new objectvar dojo = {} is the same as var dojo = new Object() Link to comment Share on other sites More sharing options...
aspnetguy Posted November 23, 2006 Author Share Posted November 23, 2006 Thanks,Any idea about the major: 0, minor: 0 stuff inside the object?Is that methods and properties of the object??? Link to comment Share on other sites More sharing options...
aspnetguy Posted November 23, 2006 Author Share Posted November 23, 2006 I did some testing and it is indeed how to define methods and propertiesa:0 is the same as this.a = 0example var obj = { param1: "hello"}alert(obj.param1) //pops up "hello" Link to comment Share on other sites More sharing options...
Beta Posted November 27, 2006 Share Posted November 27, 2006 its like this:var cur = {$1: "test",$2: "test2"}andvar cur.$1 = "test"; var cur.$2 = "test2";and you use them by eithercur.$1 or cur['$1']you can also use functions=P Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now