I have an object cats
like this:
var model = {
cats: [
{
name: "Fossie",
url: "",
count: 0
},
{
name: "Bootsie",
url: "",
count: 0
}
],
currentCat: cats[0], //error here
}
When I try to access cats[0]
, I get following error: ReferenceError: cats is not defined
If I replace cats[0]
with this.cats[0]
I get this error: Uncaught TypeError: Cannot read property '0' of undefined
Is it not possible to access an object's property within the same object? Or should I create a function inside model
and initialize currentCat
in there?