In the code below why
alert(window.concatenateAandB());
works fine and displays "Hello world"? I know based on the tip from http://java.dzone.com/articles/javascript-java-developers this refers to current object which is "window" but again I dont get it! I am from Java background and thought the right version would have to be
window.Simple.concatenateAandB()
can anyone helped me out here?
function Simple(a, b) {
var propertyA = a;
var propertyB = b;
this.concatenateAandB = function() {
return propertyA + propertyB;
}
}
Simple("Hello ","world")
alert(window.concatenateAandB());