Breaking News

JAVASCRIPT: AN INTRODUCTION (Chapter1) (#BCANotes)(#MCANotes)(#JSTutorial)(#ipumusings)(#CSENotes)

JAVASCRIPT: AN INTRODUCTION




CHAPTER 1:

HOW WEBSITES USED TO WORK WHEN THERE WAS NO JAVASCRIPT? IS JAVASCRIPT NECESSARY?

-What used to happen earlier was, let's take an example of a 3-Step Registration Form, which usually sites implement, especially the bank sites, for taking your details. You started filling your form. You entered your FirstName, MiddleName, LastName, then your username, then your email, then your Password, Home Address, Permanent Address, Bank Account Number, Aadhar Card Number, Date Of Birth, Profession, Mother's Name, Father's Name, and so much further. By now, you are correlating with how long this form is. Finally, you filled in all the details to the best of your knowledge and clicked the submit button. 

Phewww, a sigh of relief, isn't it?

But then, instead of showing you the message, "Your form has been submitted." It shows an error, that "Your Password must be of more than 8 characters and must use a special character as well. Fill your form again." 

Again, a blank form with all the details swapped off comes back to you, this time maybe you skipped filling in the last name. Again, after the submit button, it comes to you that 'Last name cannot be blank.' Eventually, you will be able to fill the form, but isn't it tiresome? 

What was happening in this that a round-trip to the server was needed to check the form fields if a required field had been left blank, or an entered value is invalid, for any such thing, the process, it wasn't friendly to the users. 

JavaScript that came in 1995 was having the main purpose to handle the input validation that had previously left to the server-side languages like PERL. 

The capability to handle some basic validation on the client-side was such an exciting feature that made programmers using Javascript as a Client-side scripting language, mainly for form validations. 

What it means is that now when you start filling your form, if you have left any required field blank, it will show a message then and there only, that you have left this blank. This makes it easy for the user to fill in the validated details before the final submission of the form.

IS JAVASCRIPT LIMITED TO CLIENT SIDE VALIDATIONS ONLY? IS IT CAPABLE FOR DOING VALIDATIONS ONLY?

No. The rise of JavaScript from a simple form-validator to a full-fledged powerful programming language could not have been predicted. It is at once a very simple language and very complicated language that takes minutes to learn and years to expertise. 

JavaScript has risen to an important interactive feature for every major web browser, nearly all aspects of the browser window and its content. It is recognized as a full programming language, capable of complex calculations and interactions, including closures, anonymous(lambda) functions, and even dynamic and metaprogramming. 

It has become such an integral part of the Web that even alternate browsers, including those on mobile phones and those designed for disabilities, support it. VBScript, that was introduced by Microsoft, ended up using JavaScript implementation in Internet Browser from its earliest version. 

It is now clear how much potential JavaScript has. It's important to understand its nature, history, limitation, and implementation. 

WHEN DID JAVASCRIPT COME IN ACTION? WHEN WAS IT RELEASED, BY WHOM?

A SHORT HISTORY

Brendan Eich, who worked for Netscape, began developing a scripting language in 1995 called Mocha, which was later called LiveScript, for the release of Netscape Navigator 2. The intention was to use it in both the browser side and on the server-side (where it was to be called LiveWire). 

Netscape entered into a development alliance with Sun Microsystems to complete the implementation of LiveScript in time for release. 

Just before Netscape Navigator 2 was officially released, it changed LiveScript's name to JavaScript. It was because Java was the popular buzz at that time. 


DOES JAVASCRIPT REQUIRE A COMPILER JUST LIKE C++?

No, it does not require a compiler. JavaScript is interpreted; it is not compiled. 


IS JAVASCRIPT STANDARDISED?

Yes, “JavaScript” is standardised as “ECMAScript” by Ecma International, a standards organization responsible for multiple computing standards. The ECMAScript standard is ECMA-262. ECMAScript versions have been abbreviated to ES1, ES2, ES3, ES5, and ES6. Since 2016 new versions are named by year (ECMAScript 2016 / 2017 / 2018). ECMAScript 6th Edition standard (“ES6”) defines ECMAScript 2015 became a buzzword. 


WHAT YOU CAN DO WITH JAVASCRIPT?

You can:
  • create and modify content.
  • restyle content
  • interact with HTML (forms, styles...)
  • handle events
  • change properties of HTML Window 
  • design frameworks to develop web and mobile applications.


JAVASCRIPT IMPLEMENTATIONS

JavaScript implementation is made up of the following three distinct parts:
  • The Core (ECMAScript)
  • The Document Object Model (DOM)
  • The Browser Object Model (BOM)
The HTML page is constructed as a tree of objects and is called the Document Object Model (DOM). By using JS, (DOM) elements can be accessed and manipulated.

The Browser Object Model (BOM) is used to interact with the browser. It is not an official standard, BOM is a collection of methods and properties implemented by browsers to control browser attributes like frames, server requests, current URL and functions like alerts.HTML5 APIs are significantly playing a major role in standardising these parts. 


HOW WEB BROWSERS IMPLEMENT JAVASCRIPT?

Web browsers embed their ow JS engines which parse and execute JS scripts.

- Google’s Chrome browser uses their V8 engine (also used in Chromium, Opera, and Microsoft Edge v79 and later)

- Apple’s Safari browser (for Mac OS and for iOS) uses their JavaScriptCore engine

- Mozilla’s Firefox uses their SpiderMonkey engine

- Microsoft IE implements its engine called JScript, which has become a bit outdated now. Microsoft Edge v44 (and onwards) uses a new JS engine called Chakra engine.

JavaScript engines are also used in desktop-based or server-side applications like Electron,4 React Native, NodeJS etc.

In the next post, we shall learn various ways to implement JS scripts in browsers.


👉See Also: