How many times you had problem or were asked about what happened to this object in your function? Or why this is not an object you expect it to be? Probably these times you have to remind yourself or your fellow programmer about function context.
First of all I have to ask you all a pretty lame question. If you write function in JS block right inside your HTML, what this keyword will refer to?
<script type=”text/javascript”>
function testThis(){
//who is “this”
}
</script>
And now to the real example.
Let’s say you build a simple Javascript object:
<script type=”text/javascript”>…
[ Read the rest of the story in the original article... ]
Related Articles:(This is an automated generated content. If you are the owner of this article and don't want to show this here, just write me at post@12n3.net and I'll remove it immediatly)