When using setTimeout(), setInterval(), or requestAnimationFrame()

Remember that the scope of 'this' will be global when the callback function for a setTimeout() is triggered. Same goes for setInterval() and requestAnimationFrame().

This one has gotten me more than once.

// This won't work...
someObject.someMethod = function(){
requestAnimationFrame(function(){
this.someOtherMethod();
});
};

 

This will work:

someObject.someMethod = function(){

var self = this;
requestAnimationFrame(function(){
self.someOtherMethod();
});

};

Add a Comment...

 

Comments

Revolutional update of SEO/SMM package "XRumer 16.0 + XEvil 3.0": captcha solving of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex, and more than 8400 another types of captcha, with highest precision (80..100%) and highest speed (100 img per second). You can connect XEvil 3.0 to all most popular SEO/SMM software: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other software. Interested? There are a lot of introducing videos about XEvil in YouTube. Good - 7/22/2017

best mattress 2017 for side sleeper [url=http://valdesystems.com/]top rated mattresses for 2017[/url] rate mattresses 2017 mattresses 2017 [url=http://valdesystems.com/]the best mattresses 2017[/url] mattresses 2017 best mattress to buy 2017 [url=http://topmattressreviews.org/best-mattress-to-buy-in-2017/]macy mattress sale 2017[/url] best rated hybrid mattresses 2017 the best rated mattress 2017 [url=http://bestmattressreviewsandratings.com/best-mattress-to-buy-in-2017/]best mattresses in - 7/22/2017

Revolutional update of SEO/SMM package "XRumer 16.0 + XEvil 3.0": captcha recognition of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex, and more than 8400 another categories of captcha, with highest precision (80..100%) and highest speed (100 img per second). You can connect XEvil 3.0 to all most popular SEO/SMM programms: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other software. Interested? You can find a lot of introducing videos about XEvil in Yo - 7/22/2017

Revolutional update of SEO/SMM package "XRumer 16.0 + XEvil": captcha breaking of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex, and more than 8400 another types of captchas, with highest precision (80..100%) and highest speed (100 img per second). You can connect XEvil 3.0 to all most popular SEO/SMM programms: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other software. Interested? You can find a lot of demo videos about XEvil in YouTube. See you l - 7/22/2017

Absolutely NEW update of SEO/SMM package "XRumer 16.0 + XEvil 3.0": captchas solution of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex, and more than 8400 another categories of captchas, with highest precision (80..100%) and highest speed (100 img per second). You can connect XEvil 3.0 to all most popular SEO/SMM programms: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other programms. Interested? There are a lot of introducing videos about XEvil in You - 7/22/2017

Revolutional update of SEO/SMM software "XRumer 16.0 + XEvil 3.0": captcha recognition of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex, and more than 8400 another size-types of captcha, with highest precision (80..100%) and highest speed (100 img per second). You can connect XEvil 3.0 to all most popular SEO/SMM programms: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other software. Interested? There are a lot of introducing videos about XEvil in YouT - 7/21/2017

Absolutely NEW update of SEO/SMM software "XRumer 16.0 + XEvil 3.0": captcha breaking of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex, and more than 8400 another categories of captchas, with highest precision (80..100%) and highest speed (100 img per second). You can connect XEvil 3.0 to all most popular SEO/SMM programms: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other software. Interested? You can find a lot of impessive videos about XEvil in You - 7/18/2017

Absolutely NEW update of SEO/SMM package "XRumer 16.0 + XEvil 3.0": captchas solving of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex, and more than 8400 another subtypes of captchas, with highest precision (80..100%) and highest speed (100 img per second). You can connect XEvil 3.0 to all most popular SEO/SMM programms: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other programms. Interested? You can find a lot of impessive videos about XEvil in YouTu - 7/17/2017

Revolutional update of SEO/SMM software "XRumer 16.0 + XEvil": captchas breaking of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex, and more than 8400 another types of captcha, with highest precision (80..100%) and highest speed (100 img per second). You can connect XEvil 3.0 to all most popular SEO/SMM software: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other software. Interested? There are a lot of introducing videos about XEvil in YouTube. Good - 7/14/2017

Hello there! This article couldn't be written any better! Reading through this post reminds me of my previous roommate! He continually kept talking about this. I'll send this article to him. Fairly certain he's going to have a great read. Thank you for sharing! - 6/02/2017

Howdy would you mind letting me know which web host you're using? I've loaded your blog in 3 completely different browsers and I must say this blog loads a lot quicker then most. Can you suggest a good internet hosting provider at a honest price? Thanks, I appreciate it! fotbollskläder barn - 5/16/2017

JohnMcAlr Liverpool EstebanPi StaciaLwc Elfenbenskusten RonStubbs EliBaylee Elfenbenskusten ScottClor RitaCorby Osterrike MadelineN TaneshaOi Valencia LVUBruce - 3/08/2017