In the world of programming, a variable is like a chameleon - it can adapt to any situation and always remain a variable. Thanks to JavaScript's dynamic typing, a variable has the ability to change its type based on what it holds.
When you first introduce a variable in your script, it starts off as undefined. But as you start assigning values to it, that undefined state transforms into something concrete.
Additional insight from comments:
Remember, a variable remains undefined until you give it a purpose by assigning a value to it.
var word; //word is undefined
Once you assign a value to 'word' in your code, it becomes more than just a placeholder - it now holds either a primitive value or points to an object.
word=c.get('chats')[ch];//Now it has a primitive value or a pointer to an object
Despite this transformation, the contents of 'word' at this point remain unknown.
In JavaScript, objects can be accessed using two different syntaxes: obj['property'] or object.property.
word['comments'] //word is pointing to an object
It seems like you're opting for the former method to access 'word', implying that it was indeed assigned an object earlier.
Finally, when you reference 'word['comments']', you treat it as though it were an array (or an object with numeric indices and a length property).
word['comments'].length
word['comments'][i]
Just remember that in JavaScript, variables serve as pointers to objects rather than actual objects themselves.