Quote:
Originally Posted by oldskool ^ If you are using a compiler. For Javascript you can use Notepad, and some people do. Javascript doesn't get compiled, like the other languages mentioned. The browser "renders" it, but Javascript doesn't get compiled. It is not a stand-alone application, just code used within HTML in the form of a script.
^^ Yes the moral of the thread is be careful, but don't let it end like that. I was just trying to think of some obvious mistakes.
^ Yes that would be an error, if you try to say:
If (someVariable = someOtherVariable) {
// the code here wouldn't work if, if "someVariable were equal
//to 5 and someOtherVariable = 5 as well.
}
That is because the code is NOT COMPARING the two values. It is trying to make
someVariable receive the value of someOtherVariable, not compare the two.
What would be needed in this case would be the == .
So you are wrong, Soulphire. Sorry. Unless you can show me what you mean, with an example. |
What soulphire is saying (and he is right) is that
Code:
if (something = another)
is not a syntax error, put that into a compiler and it will be fine (which is what makes it is so tricky). If the compiler produced an error as in the case of a syntax mistake eg. a missing '}' or ';' then it wouldn't be such a problem.
Interestingly enough, according to standards (note that I have not read the standard myself to verify this) javascript does not require semicolons though they are considered good practice. And while you are right to note that javascript is an interpreted language and as such is not compiled, you can usually set the browser to pop up with an error if there is a problem.
EDIT: if anyone wants an example of why this isn't a syntax error (although arguably it should be) then I would be more than happy