[Solved] Backbone treat model like collection


Since Collections is actually a model

No. This is wrong assumption. Collection is not a model which is why your code doesn’t work.

Model does not have an each method and your code throws following error:

Uncaught TypeError: this.model.each is not a function(…)

and don’t follow the other answer that iterates over model properties and prints it’s name, it doesn’t make sense. Because model is supposed to represent an entity, like a person. It’ll only have one property containing name, there’s no point in iterating over model properties to access one of them, you can directly access it’s attributes with get() method without having to iterate.

7

solved Backbone treat model like collection