请有人告诉我为什么下面的第 1 行会引发错误
Uncaught TypeError: Cannot read property 'age' of undefined.
我是 javascript 和骨干网的新手,这个错误对我来说毫无意义。
谢谢
<script>
var Person = Backbone.Model.extend({
initialize: function(){
console.log("Person is initialized");
}
});
var People = Backbone.Collection.extend({
model: Person,
initialize: function(){
console.log("People model is initialized");
}
});
var person = new Person({age: 12});
var person2 = new Person({age: 15});
var person3 = new Person({age: 12});
var people = new People();
people.add(person);
people.add(person2);
// (1) var ages = _.where(people, {age: 12});
console.log(ages);
</script>