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 can set the scope of a function using the JavaScript call or apply functions. Maybe see this [tutorial](http://odetocode.com/blogs/scott/archive/2007/07/05/function-apply-and-function-call-in-javascript.aspx) for details on how they work.

By setting the scope, you can set "this" to be whatever you want.