I am somewhat new to JavaScript and I have a question.
I know you can set variables and “sub-variables”. Like:
var msg = "Hello World";
alert(msg);
and also
var msg = {
lipsum: "Lorem Ipsum Dolor Sit Amet"
}
alert(msg.lipsum);
But I was wondering if you could do both, like
var msg = "Hello World" || {
lipsum: "Lorem Ipsum"
}
alert(msg + msg.lipsum);
That way, you can declare a variable and also have the same variable be an object. Obviously it couldn’t be done with what I did, but you get the picture.
Any help would be much appreciated!
Actually, you can.