View Single Post
Old 11-10-2012, 07:05 PM   PM User | #1
bunzu
New Coder

 
Join Date: Jul 2012
Posts: 10
Thanks: 3
Thanked 0 Times in 0 Posts
bunzu is an unknown quantity at this point
Accessing local objects?

Hey Guys,

I'm running into a bit of problem accessing my objects. I'm trying not to duplicate code base or update multiple instances of the same number. This is what I'm trying to do:

Working:
Object = {
test: {
time: new Date().getTime,
duration: 2000,
test: setInterval(function(){
console.log("hi hi");
}, 2000) }
}
Object.test();


Not working:
Object = {
test: {
time: new Date().getTime,
duration: 2000,
test: setInterval(function(){
console.log("hi hi");
}, this.duration) }
}
Object.test();

Notice I changed the 2000 to this.duration hoping I can just set the duration once.

Any help would be great.
Thanks!
bunzu is offline   Reply With Quote