• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

javaScript Objects or structs ?

 
Ranch Hand
Posts: 681
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I am extremely new to JavaScripting and am learning what you can or cannot do with JavaScript.
I have created a function in which I can pass in three items, a image, a string and a url.
What I would like to do is pass in a Object, or at least a C struct like item that will contain all three items.
Is this possible in java script.
Thanks for any help.
Tony
 
Sheriff
Posts: 67762
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In JavaScript you can create objects and assign attributes to them on-the-fly.
For example:

or you can get all OO about it (recommended) and actually create a new reusable JS class:

and using the .prototype attribute you could even give this JS class methods (such as accessors and mutators for the members, or other methods that may be useful).
I highly recommend this book to learn what you can do with JavaScript.
hth,
bear
 
Tony Evans
Ranch Hand
Posts: 681
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bear Bibeault that was a great help.
Cheers Tony
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic