JavaScript: Part -1

Why JavaScript.

JavaScript is an important language because it the language of the web browser. Its association with the browser makes it one of the most popular programming language in the world.

The amazing thing about JavaScript it that it is possible to get work done with it without knowing the much about the language.

Analyzing JavaScript

JavaScript is build on some very good ideas and some very bad ones. The very good idea includes functions, loose typing, dynamic object and expressive object literal notation.

The bad idea includes a programming model based on global variable.

JavaScript functions are first class object.JavaScript is the first lambda language to go mainstream. Deep down, JavaScript has more in common is Lisp and Scheme than with Java. JavaScript is a loosely typed language, So JavaScript compliers are unable to detect type error and this can be alarming for people who are coming to JavaScript from a strongly type language. But it turns out that strong typing does not eliminate the need for careful testing.

JavaScript has a very powerful object literal notation. Objects can be created simply by listing their components. This notation was an inspiration for JSON, The popular data interchange format.

The controversial feature in JavaScript is prototypal inheritance. JavaScript has a class free object system in which objects inherit properties directly from other objects. If you try to apply classical design to JavaScript directly you will get frustrated. But if you learn to work with JavaScript’s prototypal nature, your efforts will be rewarded.

JavaScript depends on global variable for linkage. All of the top level variables of all compilation units are tossed together in a common namespace called the Global object. This is a bad thing because global variables are evil, and in JavaScript they are fundamental. Fortunately JavaScript also gives us a tool to mitigate this problem.

The Standard that defines JavaScript (aka JScript) is the third edition of The ECMAScript Programming language.

JavaScript is a language for many contrasts. It contains many edges and sharp edges, So you might wonder, “Why Should i use JavaScript?”

There are two answers.

The first is that you don’t have a choice. The web is become so important platform for application development, and JavaScript is the only language found in all web browsers.

The second is that despite of all its deficiencies JavaScript is really good. It is light-weighted and expressive. Once you get the hang of it functional programming is a lot of fun.

But to you the language well you should be aware about its limitations.

A Simple Testing Ground.

If you have a web browser and any text editor, you have everything you need to run JavaScript programs.

First make an HTML.file with a name like program.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>javascript-training</title>
</head>
<body>
    <pre>
        <script src="program.js"></script> 
    </pre>   
</body>
</html>

Than make a file in the same directory with a name like program.js:

document.writtenIn('Hello JavaScript');

open your HTML file in your web browser to see the result. Throughout the blog a method will be define new methods.

Function.prototype.method = function (name, func) {
this.prototype[name] = func;
return this;
};
/* This will be explained in future blogs */

Thankyou!

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: