Friday, January 18, 2013

How To Learn JavaScript The Easy Way

By Shanna McNeil


The best way to learn JavaScript or any other programming language is to understand its usage and the functionality it offers within said applications. In this case, JS is a web browser language. Specifically, it is a platform independent and client-side language.

JS does not need a compiler and a development environment in order to make the program executable. A snippet of JS code inserted into the HTML source code of a web page will ensure the script is called and executed by the browser. Don't worry if this sounds too complicated. It'll all be clear soon enough after a few practice runs.

JS adds interactive functionality to a static web page which has nothing but HTML and CSS in the source. This would be a good time to point out that both CSS and HTML are prerequisites for those planning to work on JS. However, it does really require any prior programming skills or experience, so JavaScript is an ideal language for first-timers.

Many people are also confused between JavaScript, Java and jQuery. Both JS and Java are OOPs (object oriented programming languages) with a lot of similarities in structure. However, JS is simpler and can be easily learned by following simple logic and syntax. JQuery is a library, which means it has prebuilt JS code which can be inserted into the script.

All that is really required to get started is a text editor and a web browser. There is no software to be downloaded and installed. It does not need a special compiler or programming environment. Just write the JS code in a text file, save it, and then open this file in the browser. That's all there is to it.

It might be easier to grasp by looking at a sample piece of code and testing it in a browser. The syntax could not possibly be any easier. The JS script will be the one inside the tag, which lets the browser know this is not a part of the HTML. Adding the type="text/javascript" attribute to the script tag indicates this script is a snippet of JS code.

The rest is pure OOP, requiring creation of objects, arrays and variables which are then assigned values and properties. Learn how to use them by setting up a few simple conditional statements and loops. It's hard to go into more detail about the syntax and OOP in this limited space. But there's no question that learning to do all this in JS is much easier than with Java, C or C++.

Once the basics are clear, start using jQuery and other JS libraries to build complex scripts that are actually used in practical applications. Inserting calls to these library functions ensures the program does not have to be coded line by line from scratch, and it will reduce the coding work load by a huge amount. Readers who have come this far and are able to do most of the things mentioned above will learn JavaScript in a few hours or a day at most.




About the Author:



No comments:

Post a Comment

Note: Only a member of this blog may post a comment.