Now something about make me confused again. In the file, i see the following codethis.xCenter = options.xPos; however, i can not find the place define xCenter in this object. And then i add a line like this.myattr = 12;, to my surprise, the code run normally and did not show any error. before i know the running result, i think the code should be running unsucessfully because this did not define the property of myattr, so i’m confused. That’s really different from syntax of Java. In turn, i think it’s a way define/add a perperty for an object, is my assumption right, or just the code means something else, guys?
Now something about make me confused again. In the file, i see the following
Share
Javascript is a dynamically (and weakly) typed language. You can add properties as and when you want. They do not need to be declared first.
For example :
Java on the other hand is a statically (and strongly) typed language, thus variables and properties have to be declared before being used.