Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2010
    Posts
    121
    Thanks
    0
    Thanked 3 Times in 3 Posts

    point of objects

    So, I am reading the book, "eloquent Javascript" and it must say it is a very poorly written book. It doesn't explain as to why things work the way they do in javascript and just basically says, "do this" and thats it. But that's beside the point.

    What is the point of objects? all to often, I find tutorials, and other things about beginners guides on how to do things, but many of them (99.9999% of them) don't tell you what it can be used for. I had this trouble with arrays.

    Can someone enlighten me to what the point of objects are? Please don't just tell me, "they ar a type of value where properties can be freely added, removed, or changed". Give me a eveyrday language type of explanation.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,037
    Thanks
    203
    Thanked 2,539 Times in 2,517 Posts
    In Javascript everything is an object. An object is a collection of properties, and a property is association between a name and a value.

    Have a look at:-

    https://developer.mozilla.org/en-US/...g_with_Objects


    Frustration - the first time you can't do it the second time.
    Desperation - the second time you can't do it the first time

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,350
    Thanks
    11
    Thanked 589 Times in 570 Posts
    an object is like a row of a spreadsheet, the header row of a spreadsheet is like a class or constructor.

    if i want a playlist, it would be nice to be able to sort by year, title, artist, etc.
    in js, each playlist item would be an object, and the list itself is an array (if you needed one). arrays are just objects that use 1, 2, and 3 instead of a, b, and c.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •