From the course: JavaScript Essential Training

Unlock this course with a free trial

Join today to access over 22,500 courses taught by industry experts.

JavaScript language basics

JavaScript language basics

- [Instructor] JavaScript has some very basic language basics worth knowing about. First, write your JavaScript from top to bottom because that's how the browser will read it. A good rule of thumb here is to define all variables and functions and objects and anything else before you use them, so higher up in the file. That way you know the browser has read the object or the function or whatever it is before you call it, otherwise you might run into problems. Second, comments, like what you see at the top here are used to leave literal comments for yourself and other humans to explain what's going on. When you create a comment it is ignored entirely by the browser, so it's purely there for us humans. In my code editor right now with the color settings you can see comments are colored green. They'll always have a different color from other code and it's always consistent in the way you see here. To leave a single line…

Contents