What is JavaScript

W

JavaScript is a fully developed and dynamic programming language that, when used with an HTML document, can provide dynamic site interactivity. It was invented by Brendan Eich, one of the founders for Mozilla project, Mozilla Foundation and Mozilla Corporation.

JavaScript is a scripting language generally used as a client-side scripting language for web applications.

JavaScript can be used within other contexts as well, there is also a server-side JavaScript version, but not as popular as the client-side version.

The language has initially been named LiveScript and was created with the purpose to provide simple scripting language to modify HTML web pages on the client side dynamically.

Owing to the fact that before the creation of the language, Java was at an unprecedented peak of popularity, the creators decided to change the name of LiveScript to JavaScript for commercial reasons. However, Java and JavaScript have little in common.

The fact that you need a browser to interpret the JavaScript language has brought some disadvantages in its usage. In the first years after it was first developed, using JavaScript was a difficult task due to the lack of a standard owing to the rapid evolution in the browser world and mainly due to the evolution on different roads of the dominant companies, meaning Microsoft, Netscape, and Opera manufacturers. The same JavaScript code when used for Internet Explorer, Netscape, and Opera rarely produced the same result. There have also been significant differences in output when using successive versions of the same browser. For these reasons, most scripts had to be written in several related modifications, which was particularly bothersome to developers. It also took a long time to produce any advanced development and debugging environments. This step took a while to overcome until the technology was mature enough and now it is an advanced technology that is widely used. With the advent of Web 2.0 and AJAX, JavaScript has grown in popularity in today’s wide range of web applications, with providers such as Google Mail and Yahoo Mail using this technology.

JavaScript itself is quite compact but still very flexible. Developers have written a wide variety of tools based on JavaScript, unlocking a vast amount of extra functionality with minimal effort. These include:

1. APIs built-in web browsers, offering features such as dynamic HTML creation and CSS styles setting, collecting and manipulating a video stream from the user’s camcorder, or generating 3D graphics and audio monitors.
2. Third-party APIs to allow developers to integrate functionality into their sites from other content providers such as Twitter or Facebook.
3. Frames and third-party libraries that you can include in HTML code that allow you to build sites and apps quickly.

Create and use function classes in JavaScript

In JavaScript, functions can also be used to create a kind of “classes” that can be the basis of an Object (defined as “new”).

Such a class in JavaScript is created using the word: function, with this syntax:

nameClass = function () {

A class contains variables (called “properties”) and functions (also called methods) that may be public or private.

Private functions and variables are defined in the class using the word “var”. These can only be accessed in the class code.

Variables and public functions are created using the word “this”. They can be accessed inside and outside the classroom.

Full syntax for creating a function class in JavaScript:

nameClass = function () {
var varPrivate = 'value_private';
var functionPrivate = function (/ * parameters * /) {
this.variablePublic = 'public value';
this.functionPublic = function (/ * parameters * /) {

Then the code that creates an object using this class can be like this:

myObject = newClass ();

Access properties and class functions

After “class” is created and an object is set with it, you can access/use the functions and properties defined in the class using the object name.

Syntax:

myObject = newClass ();

Set value to a public property:

myObject.variablePublic = 'value';

Call a public function in the class:

var method = myObject.Public function (/ * parameters * /);

The variables and public functions created in the class (with “this”) can be accessed inside the class also by the word “this” (as defined).

Parameters can be added to the class definition, so when creating an object with that class, a value for the parameter must be added.

Syntax:

nameClass = function (parameter) {
myObject = newClass name ('value');

About the author

Ilias spiros
By Ilias spiros

Recent Posts

Archives

Categories