December 17th, 2012, 09:34 AM
It only actually tells users how to run JS code on page 311, where users are told of the following solutions:
- Inline, between a pair of <script> and </script> tags
- From an external file specified by the src attribute of a <script> tag
- In an HTML event handler attribute, such as onclick or onmouseover
I was wondering what professional JS developers use to write and test their code: Do they use a good text editor with syntax high-lighting + autocompletion, hit F5 in the browser to reload the page every time they make a change, and use some add-on in the browser to investigate errors? Or are there full-fledged IDE's similar to MS VisualStudio for non-web languages?
<strike>Edit: For instance, I wrote this piece of code, which doesn't work (nothing displayed on screen when calling index.html), but Firefox doesn't display any error. How would I go trying to understand why it's not working?</strike>
Firebug showed that a .js file shouldn't contain <script>...</script> lines.
December 17th, 2012, 01:43 PM
Are you using an external script file?
If you are using an external stylesheet, you don't need to add the <script> tags.
Also, try putting a console.log() statement with variables to check their value.
Hope this helps,
December 18th, 2012, 09:44 AM
Thanks for the input.
So the standard tools used by JS developers:
- Firefox and the Firebug add-on
- a good text editor with syntax highlighting, and ideally code autocompletion
- hit F5 to test every time a change is made to the JS source code
- console.log() statement with variables to check their value.
Could someone recommend a good text editor for Windows that supports JS code autocompletion?
December 18th, 2012, 05:16 PM
Number 1: is a 100% must in my opinion and I think in most developers opinions.
Number 2: I agree with using an editor with syntax highlighting but I don't think autocompletion is a necessity. Each to their own but that kind of thing annoys me.
Number 4: I only console.log() something if I get an unexpected result, for instance I might get an error in firebug, or sometimes the console.log() might not work inside a function so I know if it's a passed parameter then the issue could potentially be there so it even gives you an idea of where the error could lie. I think it will log most errors for you.
hope this helps.