JavaScript is a scripting language that was designed for adding functionality to web pages. Also known as ECMAScript, JavaScript is an object oriented programming language.
Although JavaScript is primarily used on web pages, it isn’t limited to this application. JavaScript can also be used in PDF documents, desktop widgets, and site-specific browsers.
Although JavaScript bears a similar name to Java (programming language), they are unrelated and they are two completely different languages.
Server-Side vs Client-Side
Although JavaScript can be run on the server side (i.e. as a “server-side script”), it is much more commonly used as a client-side script. In this context, the “client” is the user agent that’s rendering your web page. So if a visitor is viewing your website through their web browser, the JavaScript code will be run and interpreted via the web browser – just like HTML.
A key benefit to running JavaScript as a client-side script (as opposed to server-side) is speed. Client-side scripts execute almost instantly. This gives the user a better experience – they don’t need to wait for the script to execute on the server and come back to the page.
Why Use JavaScript?
JavaScript has become such an integral part of the web, that it is an essential part of any web developer’s skillset. If you know how to code HTML and CSS, learning JavaScript is the next logical step.
Often when creating websites, developers find HTML too limiting. There are things that just can’t be done using HTML alone. This is where JavaScript comes to the rescue. JavaScript is usually used on a web page when it requires functionality that isn’t supported by HTML. For example, JavaScript is commonly used to provide the following functionality to websites:
- Form validation. For example, when a user submits a web form, JavaScript can be used to check that they’ve completed all fields with the correct data type (eg, the email address looks like an email address, the phone number looks like a phone number, etc).
- Pop up windows.
- Dynamically displaying information based on user input. For example, if a user selects their country from a drop-down menu, JavaScript could be used to automatically populate another drop-down menu with the states within that country.
- Advanced user interface widgets. For example, JavaScript could be used to display a navigational menu with menus that drop down when the user hovers over a menu item.
These are just some of the more popular uses for JavaScript. Once you get an understanding of JavaScript, you will see that the possibilities are virtually endless.
Should I Learn JavaScript?
If you only use a publishing system (such as a website builder, CMS, or blog software, to maintain your website), you won’t need to learn JavaScript. Of course, there’s nothing to stop you from learning it anyway. Why not?
However, if you intend to build your own website by coding it yourself, you should definitely learn JavaScript. I recommend learning HTML first, then CSS, then JavaScript.
How Do I Learn JavaScript?
There are many books on the subject of JavaScript, however, you might find it easier to start with a tutorial such as the JavaScript tutorial at Quackit. You could also check out the main JavaScript page to see examples and code snippets that will give you a quick insight into how the language works.