jimfog Posted July 1, 2013 Share Posted July 1, 2013 Recently, in a tutorial I came across with this syntax: var prop, obj = { name: "Joe", job: "Coder", age: 25 }; I really cannot understand what the prop is doing there. It is like assigning the object to 2 variables, furthermore in the w3schools tutorials about object creation I saw nowhere similar syntax. So, what the above means? Unless the writer of the code is making a mistake. Link to comment Share on other sites More sharing options...
jeffman Posted July 1, 2013 Share Posted July 1, 2013 A single var keyword can initialize an arbitrary number of variables as long as they are separated by a comma. At the same time, you can set an initial value for any of them. In this case, only the second variable is being initialized to a value. Link to comment Share on other sites More sharing options...
thescientist Posted July 2, 2013 Share Posted July 2, 2013 similar syntax to var prop;var obj = { name :"Joe", jon: "Coder", age: 25 }; Link to comment Share on other sites More sharing options...
jimfog Posted July 2, 2013 Author Share Posted July 2, 2013 got it,thanks both of you 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