Dojo - How to keep the widget's scope
However, sometimes we want to keep the scope. This is often solved by putting "this" in a variable, like the example below. This way both console.logs prints the Foo object.
In Dojo there is a built-in function, hitch, which can keep the scope. This can come in handy when developing Dijit widgets.
In the example below hitch forces the on method to retain the original scope. In this way we keep "this" inside the callback, and we do not need to create a variable for "this" like we did above.