The function textuses an internal value this.
The value thisdepends on how you call the function.
When you call $("#someElement").text(), you call it in the context of the jQuery instance. JQuery instances have a method empty.
When called, f()you call it in the context of the default object ( window). windowdoesn't have a method empty.
source
share