If your're not in ES5 strict mode, you'll add the function .clean() to the global object.
So, just calling clean('test'); would indeed work here. If you want it like you described, you need to return the function an object.
var someVariable = function() {
return {
clean: function(obj) {
alert(obj);
}
};
};
If you are in ES5 strict mode, this code would throw an error, since this would be bound to null. What the this context variable is referenced to, always depends on how the function is invoked. In your case, as described, this is either window or null.
It would also work, if you'd invoke your function with the new keyboard:
new someVariable().clean('test');
That is because, new makes the function a constructor function and this is always bound to a newly created object within the function.