Monday, 18 April 2016

P3 (5/6) : Describe the purpose and function of JavaScript and jQuery

P3: Describe the purpose and function of JavaScript and jQuery

Introduction

JavaScript is a scripting language that is normally used in the development of HTML and CSS websites. JavaScript contains many features of a programming languages but it is not a programming language because it doesn’t possess key attributes that most programming language possess. JavaScript is a client side and not server side. For this reason, this document is going to be set within the parameters of describing the purpose of JavaScript and its key features that makes it similar to programming language and exploring features that also makes it dissimilar to a programming language. The functions of JavaScript and JQuery as a development tool is also going to be explored in this document.

JavaScript

JavaScript can be described as a scripting language that is used for the sole purpose of making web pages interactive. JavaScript is an interpreted language for this reason, it runs on the client computer and you do not need an extended program in order to run it on your computer. (Tech, 2015) JavaScript is executed by web browsers and it is mainly used for interactivity and validation. JavaScript can change HTML content in the development of a site and one of the methods that it uses is through ‘getElementById()’. As well as changing HTML it can also change CSS styles. It is one of the primary ways that web developers use to validate data on webpages. For example, JavaScript is very likely to have been RUN when you don’t fill out mandatory text fields on an online form and an error message pops up. JavaScript is normally used by developers on occasion where they need the code to run after the page has loaded as JavaScript is a language that is supported by all browsers used by clients. Most interactive features of webpages such as slideshows are normally done by website developers using JavaScript. The reason why JavaScript is very popular is because of its functions that allows it to fit with the dynamic web era that we are currently in. This means that JavaScript is suitable for most sites nowadays that changes and adaption is a key aspect of the functionality of the site. For example, JavaScript is used to recognise if clients are visting the site on their phone or on a computer and then decides whether or not to change the way that the content renders to either a mobile platform version or computer version. (Wilde, 2013)

JavaScript features similar and dissimilar to programming language

Features of JavaScript that makes it similar and dissimilar to a programming language is going to be explained in the table below:
JavaScript features similar to programming language
JavaScript features dissimilar to programming language
Features such as the use of variables, conditional statement and event handlers is attributes that are normally affiliated with programming languages. This is a feature of JavaScript that makes it similar to programming languages such as Perl or C. Variables are containers for values which are norm in programming languages also conditional statements which allow different codes to run at the same time. Conditional statement is what allowed me to create validation if text boxes are not completed on a form before submission. (Wilde, 2013)
Features that make JavaScript dissimilar to programming languages is the fact that the variables that is declared with JavaScript are always made public, its features does not allow it to privatise variables as you can do with most programming languages. (Johann, 2014)
Another feature that JavaScript has in common with programming language is that it has datatype (arrays).
Another major reason why JavaScript is dissimilar to programming languages is because features that are non-existent such as algebraic data types and pattern matching that are also available with other standard programming language. (Johann, 2014)
Another reason why JavaScript is similar to a functional programing language is because functions are first class objects, there are closures and higher order of functions.

JQuery

On the other hand, JQuery is simply a library where pre-coded JavaScript are stored as open-source for developers that want to use them. JQuery is a library of JavaScript that is very popular due to the fact that it is easy to use and powerful. The main purpose of JQuery is so web developers can easily apply common JavaScripts to their websites during implementation without consuming time. JQuery functions are important as a development tool for website developers because it allows to apply JavaScript to their work without having to deal with debugging common errors. Also with JavaScript code in JQuery they are normally effective and short which helps with the implementation process of the JavaScript. (Wilde, 2013) Overall, JQuery is a development tool that most advanced website developers use due to the fewer lines code. For example, the following evidences using JQuery or JavaScript to change the background colour of a body tag: - As you can see it will be quicker to use JQuery rather than JavaScript.
jQuery
$ (‘body’) .css (‘background’, ‘#ccc’);
JavaScript
Function changeBachground(color) {
        Document.body.style.background = color;
}
Onload=”changeBackground (‘red’);”



Bibliography


Johann, 2014. stack. [Online]
Available at:
http://stackoverflow.com/questions/3962604/is-JavaScript-a-functional-programming-language
[Accessed 18 04 2016].
Tech, 2015. abouttech. [Online]
Available at:
http://JavaScript.about.com/od/reference/p/JavaScript.htm
[Accessed 18 04 2016].
Wilde, B., 2013. Udemy. [Online]
Available at:
https://blog.udemy.com/jquery-vs-JavaScript/
[Accessed 18 04 2016].





No comments:

Post a Comment