Friday, 24 June 2016

P3 - Javascript and jQuery Fundementals

P3 – JavaScript and jQuery Fundamentals
In this blog entry I will be describing the purpose and function of JavaScript and jQuery. JavaScript contains many features of a programming language but it is actually a scripting language. JavaScript is interpreted by the browser and not executed by the server, it also doesn't require any packages in order to execute, as the browser provides everything it needs in order to execute. JQuery however, is a library of JavaScript routines which make it much easier to use JavaScript on a website. it is generally used to improve the interactivity and user friendliness of a website.

JavaScript

What is Javascript?

Javascript is a scripting language which is used to make webpages interactive, it is generally used in forms such as payments and voting polls. Most web browsers support Javascript and by default have JavaScript enabled, so anything within the website that is written in Javascript will run.


What is Java?

Java is a programming language which is used to create applications that can run without requiring an internet connection, or can be distributed to a network, amongst servers and clients. Java requires a compatibility package to be installed in order for its applications to run.


How is Javascript similar to Java?

Both languages make use of conditional statements. these are essentially pieces of code that execute if a certain criteria is met. For example, validation within a form is created by using IF statements, these IF statements may declare criteria such as a minimum required age. If a number entered is smaller than the minimum required age then it may stop the user from continuing typing within the form through the use of an ELSE statement.

 
How is Javascript different to Java?

Java is an Object Oriented Programming language, whereas Javascript is an Object Oriented Scripting language. Javascript is a scripting language, not a programming language because it is directly interpreted by a browser as opposed to being compiled. A scripting language is one in which the program reading it interprets exactly what is written.

Java based programs generally require a plugin and execute as compiled programs. Also Java creates applications that run in a virtual machine or browser, whereas JavaScript code only runs on a browser. An example of this is the game Runescape which is created from Java code. It can run on web browsers and in a virtual machine dedicated to Runescape solely

Another difference between Java and Javascript is that Java is required to be installed in order for Java applications to run, whereas Javascript requires no installations as it is included within most modern browsers. 

A final difference is that Javascript was developed specifically to improve website capabilities, whereas Java is a programming language used for general purposes programming such as building applications. Javascript is purposely limited for security reasons, as it is possible for malicious attackers to manipulate Javascript code to perform tasks such as wiping hard drives through the use of scripts. One of its security vulnerabilities is Cross-Site Scripting, where it is vulnerable to malicious attacks such as manipulating scripts, to turn them malicious, which will then be delivered to site visitors.

Features of Javascript

I will be covering a few features of JavaScript, the first of which is browser support. JavaScript does not require any plugins in order to display content, unlike Flash content which requires a Flash plugin in order to be displayed. All browsers provide integrated support for JavaScript and accept it as a scripting language.

Javascript is used to create forms as it allows for validation to be implemented into the form, which functions in the sense that if a user enters an invalid email address or age, then an alert box will appear, prompting them to try again. It can also be used to implement features such as displaying the date and time and even interacting with the user, as it can write messages which will appear on screen.

Javascript allows for the implementation of validation within forms. Validation is designed to make sure no mistakes are made when writing in a form. The biggest example of validation is websites that require a valid email address in order to sign up for that website. If the email address isn't valid then a prompt will appear, usually in the form of a message box, informing the site visitor that their email was invalid.
 
Javascript also improves interactivity within websites as it can be used to interact with users in ways such as displaying the current date and time, or writing messages to the user. It is even possible to develop a website that can have a genuine conversation with a site visitor. An example of this is CleverBot. CleverBot interacts with a site visitor based on their responses. In Javascript it is possible to recreate this through the use of conditional statements. Validation prompts also improve interactivity, because the website informs the site visitor of their mistake, as opposed to allowing an invalid form to process.


JQuery

JQuery is a lightweight JavaScript library. Its purpose is to make it much easier for JavaScript to be used within websites. JQuery takes a lot of common tasks that usually require many lines of JavaScript to perform and wraps them into methods that can be called with a single line of code, making jQuery very efficient for time as programmers can spend a lot less time writing code. The jQuery library contains HTML/DOM manipulation, CSS manipulation, HTML event methods, Effects and animations, AJAX and Utilities. JQuery is used by many of the biggest companies on the web including Google and Microsoft.

JQuery is used to improve interactivity and user friendliness on a website, it allows for buttons to be animated with features such as a roll over effect in which the button will change colour when the mouse hovers over it. It can be used to animate any object within a website, with features such as hide and show effects, which can be implemented so when the user clicks on a box and it disappears, then clicks it again and it re-appears. There are many ways JQuery can be used to improve website interactivity.
 
Conclusion

In conclusion JavaScript provides browser support so it does not require plugins in order to display content, it can also be used on both the client and server side. Structures of webpages can be changed during runtime in terms of the client side. Whereas the server side uses JavaScript as an extension of the core language in order to perform tasks such as communicating with databases and file manipulations. JavaScript also provides support for objects and it contains a core set of language elements, making it versatile and popular amongst programmers. JQuery is a library of JavaScript routines which make it much easier to use JavaScript on a website. JQuery wraps common tasks into methods that can be called with a single line of code, making it very efficient for time. The JQuery library also contains many different features such as CSS manipulation and HTML event methods. Some of the biggest companies on the web use jQuery due to its functions and features as it provides a lot of efficiency



Sources: