SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member randie's Avatar
    Join Date
    Oct 2008
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    >>> Page 107, Re: submitRandomOrder.bind(this, index) - why?

    I don't get why you're calling submitRandomOrder.bind(this, index). What's the "this" variable pointing to in this context? We're not invoking submitRandomOrder or pauseThenTrade as a method on an object- looks like the "this" variable is just pointing to the global object. If so, what's the point of binding submitRandomOrder to "this"? Please explain the purpose of the bind() call - why is it needed here, and what object is the "this" variable referring to? See http://cl.ly/image/1s460d46132E .

  2. #2
    SitePoint Member randie's Avatar
    Join Date
    Oct 2008
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Never mind. I guess

    setTimeout(submitRandomOrder.bind(this, index), pause);

    is just another way of doing this:

    setTimeout(function() { submitRandomOrder(index); }, pause);


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •