The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript big time problem understanding object Reply To: big time problem understanding object


What’s the point.. What to do with them?

They’re particularly useful for grouping/scoping your code. But really, you might as well ask “what to do?” — objects are suitable for lots of things in javascript; it’s a pretty open-ended question.

also what are methods and what’s the use of them?

methods are functions that belong to an object.

var book = {};
book.color = "green";
book.size = 10;
book.describe = function(){
    var description = "This book is " +  this.color +
        " and is " + this.size + " pages long.";
    return description;