Question: I need to execute the following function in a specific context.

```
setTimeout(function () {
    myFunction();
}, 1000 * 60);

var changeDateFormat = function () {
    console.log(this); // this should be $('.myClass') 
                       // but I need to set it from setTimeout
                       // any hints
};

```

P.S.:  

I am using Underscore.js and jQuery.

Answer: 
You can use [jQuery.proxy](http://api.jquery.com/jQuery.proxy/).

```
setTimeout($.proxy(myFunction, $(".myClass")), 1000 * 60);

```

Here's an example: <http://jsfiddle.net/UwUQD/1/>

As James said you can also use `apply` as jQuery does internally:

```
proxy = function() {
    return fn.apply( context, args.concat( core_slice.call( arguments ) ) );
};

```

The first `apply` argument is the execution context (what you'll be able to access using `this`) and the second argument are other arguments you want to pass to myFunction. The `call` function is the same, but accepts additional arguments a bit differently.

---

**Or use [bind](http://underscorejs.org/#bind) in Underscore.js**

```
setTimeout(_.bind(myFunction, $(".myClass")), 100);

```

<http://jsfiddle.net/UwUQD/3/>
You could use [bind](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind) to bind the callback to the desired context.   

The downside to this being that some browsers might not support this. But sticking to the basic principles of JS, a *closure* will serve you just perfectly, too:

```
var callBack = (function(that)
{//<-- use "that" instead of "this"
    return function()
    {
        console.log(that);
    };
}($('.myClass')));//<-- pass value for that here
setTimeout(callBack,60000);

```