Ok, by now, if you are maintaining a website or thinking of maintaining a website, you may have heard of the programming languages used to create a site or app. One of those languages typically mentioned is JavaScript. Let’s cover a few basics, and some resources on where to learn more.
The Essential Definitions
JavaScript is a dynamic scripting language that can instruct the browser to make changes to page elements after loading a page. Its value is making site elements function more dynamically without requiring a call to a server. This can provide some benefits, such as improving performance loading a website page or an app in the browser.
Javascript generally appears in one of 3 positions in a website or app:
Web developers describe JavaScript as an Object Oriented Programming Language. An Object Oriented Programming Language essentially treats each element in a page as an object according to the script called in Javascript (or in another language, such as Ruby). Thus everything belongs to something else, and everything has a relationship. This structure makes it possible for an image position to be rotated or a section of text to scroll into view. The image or text sections are treated as objects.
Each object generally has a property - a property is a description of that object. Think of an object and a descriptive phrase that you would imagine if you close your eyes. An object named dish would be smooth. An object named water would certainly be wet.
Each object can be made active or dynamic through a method - an action called within a javascript script. So now think on object and an activity - a dog (object) barks (method), a sports car engine “roars”. Objects and methods are usually called through a function - statements that perform a task. A function takes the general form below:
function functionname ( ) { }
Additional parameters are described in the parenthesis, while the objects and methods - the elements and associated actions - appear in the brackets. Below is an example of a for loop function.
(The double slashes "//" are meant to provide a comment instead of a function.)
Learning about Libraries and JQuery
So with the thought of webpage elements as objects, writing a Javascript programs sounds easy, right? Not exactly. Unlike other well-known languages, Javascript is not compiled - that means there’s no need to have another program of software compile and interpret instruction. Thus JavaScript uses regular text which can be interpreted.
But every browser has its own interpreter for the text, a Document Object Model (DOM). A DOM model is an interface, a means to "talk" to different elements in a page. So Javascript has to account for that difference.
In texts and posts on Javascript or in developer gatherings, you’ll read and hear a lot about libraries (you’ll hear something similarly described in other object oriented languages, such as gems which are used in Ruby). Libraries are needed to account of different operational features of the major browsers, despite acceptance by browser makers of protocols. Browsers have different implementation of a DOM, so libraries provide a unified view of Javascript code.
Libraries are called with the following element notation:
<script src="chart.js"></script>
in which a script, chart.js, is a called as a source.
In many cases you’ll hear the name JQuery come up. JQuery is a JavaScript library, a file that highlight elements in the same style as a Cascading Style Sheet (CSS) does for a webpage. Its purpose is to provide a set of objects and methods that can be called while minimizing the interaction with the DOM for a browser. The result is a case Think of it as a sort of API which interact with the DOM in the form of a library.
Tools and Associated Libraries
To create that great method and ensure that is functions in the grand scope of your app or site, a little debugging becomes required. To debug means to review code and edit as needed. The following are tools and resources that make debugging code much easier:
Books and Website Resources
The book Javascript and JQuery by Jon Duckett has additional resources available at its supporting site, www.javascriptworld.com. I wrote a review on it at Small Business Trends. It’s an excellent modern book that offers a solid overview on Javascript and associated subjects like JSON, JQuery, and APIs.
You can also check out Programming Javascript Applications, which is a bit more advanced book but also offers insight into how to make the most of Javascript.
The site JQuery.org offers a number of resources and covers the basics on JQuery. Not only is this a good resource of JQuery-associated features like plugins, but the site can also provide some understanding of how libraries in general work.
There are online video sites, such as www.metacasts.tv - This website offer programs on Javascript techniques - there is a dedicated page for frameworks. These have a subscription price, and can be a bit advanced - users who are comfortable with GitHub will appreciate the GitHub availability.
There is good ol’ Tuts - this site hosts a number of how to related to web design and development. You can check out the site here.
You can also check out the descriptions for popular frameworks, such as AngularJS. The main site offers several tutorials, and some advanced definitions that can help one understand JavaScript much better.
Also, need a text editor for practice - consider one of these text editors outlined in this Zimana post. Sublime and BBEdit are just two of the ones mentioned here in which a user can create a JavaScript script.
[…] Older postWhat is Javascript? An Explanation and Helpful Resources […]
Great Post! Keep it up!