inner object parent variable reference

J

josh

Hi, I have an error when I try to make:

CustomObj =
{
is_all : Compatible(),

Types :
{
PASS : CustomObj.as_all ? "ok" : "onok",
...
...
...
but in an object literal notation I cannot use a parent object
variable? or
can I do to create a global variable inside my parent class
(CustomObj) and
than to use in my children objects like Types?

Thanks
 
P

pr

josh said:
Hi, I have an error when I try to make:

CustomObj =
{
is_all : Compatible(),

Types :
{
PASS : CustomObj.as_all ? "ok" : "onok",

Didn't you mean
PASS : CustomObj.is_all ? "ok" : "onok"
?
but in an object literal notation I cannot use a parent object
variable?

javascript doesn't have a 'parent' built-in variable.
can I do to create a global variable inside my parent class
(CustomObj) and
than to use in my children objects like Types?

CustomObj = new (function() {
var parent = this;

this.is_all = Compatible();
this.Types = { PASS: parent.is_all ...};
})
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,156
Messages
2,570,878
Members
47,408
Latest member
AlenaRay88

Latest Threads

Top