Static member variable containing object instances
Posted
by tom
on Stack Overflow
See other posts from Stack Overflow
or by tom
Published on 2010-05-30T04:43:38Z
Indexed on
2010/05/30
9:12 UTC
Read the original article
Hit count: 168
JavaScript
I have the following:
function Preferences() {
}
Preferences.players = {
'player1': new Player()
}
players is a static member variable of Preferences and I'm trying to make it an object containing an instance of a Player. However, it doesn't appear to let me do this. It seems like it will allow me to define players if I make it a non-static member variable however. Like so:
function Preferences() {
var players = {
'player1' : new Player()
}
}
Is it possible to create a static member variable containing instances of an object in JS?
© Stack Overflow or respective owner