I am playing around with the HTML canvas and write some text on it using Javascript.
While doing this I made a simple error which took me some time to find. I wrote:
context.fillText = ("My message", x-coord, y-coord);
The equal sign prevented the behavior I expected. But there is one thing I do not get: Why does this code not give me an error in the Javascript console of Chrome?
Is this valid Javascript? If yes: Could you explain whaat the code does when the equal sign is there?
Yes that is valid Javascript. It is using the comma operator, which just evaluates the expression on the left, then the one on the right and returns the value of the one on the right.
Since the expressions
"My message"andx-coordhave no side-effects, it is the same as:Or: