While I was trying some fundemantels in Javascript, I came across a question, which suprised me, and I cannot find an answer to that. I got the following, which works perfecty:
var obj= new Object ();
obj.test = "Hello"
obj.testTwo= function (){
console.log(this.test)
},obj.testTwo();
When I'm trying it without a comma, it does not work.
var obj= new Object ();
obj.test = "Hello"
obj.testTwo= function (){
console.log(this.test)
}obj.testTwo();
So I tried this as a third option...and it works?
var obj= new Object ();
obj.test = "Hello"
obj.testTwo= function (){
console.log(this.test)
}
obj.testTwo();
Now I'm quiet confused. Why to use a comma and why does it work with a break?