History of JS
- JavaScript was designed by Brendan Eich, an American computer programmer in Netscape Communications Corporation. They created JavaScript in September 1995 and took only 10 days to develop the scripting language, then known as Mocha.
- The name JavaScript came from Netscape’s support of Java applets within its browser.
- The first stable release of JavaScript was in December 4, 1995, when Netscape 2.0 (a web browser) was released.
- Now latest JavaScript came in the form of ECMAScript, 12th edition in June 2021.
Introduction of JS
- JavaScript is abbreviated as JS.
- Script means short programming statements to perform a task.
- Client is a node computer that establishes connection with the server,
collects data from the user, sends it to the server, receives information
from the server and presents it to the user. - The pure or original or plain JavaScript is also known as Vanilla JavaScript.
- JavaScript is not a complete programming language rather it is a scripting language. This is because JS needs to be embedded within a HTML document and also to specify an external JS file that contains the JavaScript code we use word ‘script’ or ‘program’ for the JavaScript code.
- The most common way to embedd a script code in an HTML document is to use script tag of html. We can place our JavaScript code in either the HEAD or BODY section of a HTML document.
- The code of JS can be write in any text editor such as Notepad.
- The extension name of pure JS file(external JS file) is .js whereas when with html it is .html.
- To run JS file, simply run the html file which is embedded with JavaScript code with the help of browser.
- In JavaScript, there are two types of comments(Comments are the statements that are always ignored by the interpreter. They are used to give remarks to the statement making it more readable and understandable to other programmers) :
– Single line comment using double-slash (//).
– Multiple lines of comment using /* and */ . - JavaScript(js) is now beleive that the world’s one of the most popular scripting language.
- Although, JavaScript has no connectivity with Java programming language. The name was suggested and provided in the times when Java was gaining popularity in the market.
- In other words, simply we can say that without JS we can not imagine the completion of any web applications.
- Java script mostly works with html i.e. its code is written with html codes anywhere anytimes inside script tag of html, as per need of the job but in common practice it is written in the head region of the html.
- Java script code can also be written alone in a simple editor(such as notepad) with .js extension as external js file to use furhter in an html page.
- There is no need to download or install java script separately in a computer system because it is already installed or associated with the web browser of the system.
- A java script code can perform with html and css both and also is very much compatible with php, jsp, asp, python etc.
- JavaScript is fully used across the web development work and hence it’s considered as both front end and backend.
- To run JavaScript Program, only modern browser is needed.
- Javascript is believed as a MUST for students and working professionals to become a great Software Engineer specially when they are working in Web Development Domain in modern era.
Definition of JS
- JavaScript is an object-based, lightweight, high-level, just-in-time interpreted(A JavaScript interpreter resides within almost Internet browsers), text-based, computer scripting language mainly used to create interactive and dynamic web applications or network applications.
Features of JS
- Java script is easy to learn because its syntax is very much similar to C, Java etc. languages.
- It is a case-sensitive language and its keywords are in lowercase only.
- JavaScript is very easy to implement because it is integrated with HTML.
- JS are used both on the client-side(Client-side JavaScript refers to JavaScript code that gets executed by the web browser on the client machine without any network connection.) and server-side (Server-side JavaScript is also known as “LiveWire”. Like client-side JavaScript, server-side JavaScript is also embedded within a HTML document. When a query is made by the client, web server executes the script after interpreting it.)applications that allows us to make web pages interactive.
- Java script is free to use.
- Java script is very rich in in-built funtions through which they work a lot by calling it using suitable events such as onclick, onchange, onload etc.
- It is mostly used with several other programming or scripting languages in making of interactive and dynamic web applications, hence this language is sometimes also called Web languages.
- It is open and cross-platform.
- In addition to web browsers, databases such as CouchDB and MongoDB uses JavaScript as their scripting and query language.
- Javascript is the most popular programming language in the world and that makes it a programmer’s great choice. Once we learnt Javascript, it helps us developing great front-end as well as back-end softwares using different Javascript based frameworks like jQuery, Node.JS etc.
- Javascript is everywhere, it already comes installed on every modern web browser and so to learn Javascript we really do not need any special environment setup.
- The use of JS has now extended to mobile app development, desktop app development, and game development. This opens many opportunities for us as Javascript Programmer.
- Javascript has tons of frameworks and Libraries already developed which can be used directly in our software development to reduce your time to market.
- JavaScript follows the syntax and structure of the C programming language. Thus, it is a structured programming language.
- JavaScript is platform independent i.e. it can run on any operating systems.
Types of JS
- There are two ways to embedd the JavaScript code :-
- Embedded/Inline JavaScript :
- When JavaScript code can be placed either in the HEAD or in the BODY section of a HTML document is called Embedded or inline JS.
- It is advised to place JavaScript code in HEAD section when it is required to be used more than once.
- If the JavaScript code is small in size and used only once, it is advisable to put it in the BODY section of the HTML document.
- External JavaScript :
- When the same JavaScript code needs to be used in multiple documents then it is the best approach to create JavaScript code in external JS files with extension of .js.
- To use/import the external JS file in a document, we simply use src attribute with script tag.
- Embedded/Inline JavaScript :
Uses/Applications of JS
JavaScript is mainly used to create interactive dynamic websites. In the website, it is used for:-
- In the creation of dynamic drop-down menus.
- In displaying date and time.
- In displaying pop-up windows and dialog boxes.
- In displaying clocks etc.
- Client side validation-In this, the verification of any user input is done before submitting it to the server and Javascript here plays an important role in validting those inputs at front-end itself.
- Manipulating HTML Pages– Javascript helps or used in manipulating HTML page on the fly. This helps in adding and deleting any HTML tag very easily using javascript and modify the HTML to change its look and feel based on different devices and requirements.
- User Notifications– We can use Javascript to raise dynamic pop-ups on the webpages to give different types of notifications to the website visitors.
- Back-end Data Loading– Javascript supports Ajax library which helps in loading back-end data while we are doing some other processing. This really gives an amazing experience to our website visitors.
- Presentations– JavaScript also supports the facility of creating presentations which gives website look and feel. JavaScript provides RevealJS and BespokeJS libraries to build a web-based slide presentations.
- Server Applications– Node JS is built on Chrome’s Javascript runtime for building fast and scalable network applications. This is an event based library which helps in developing very sophisticated server applications including Web Servers.
Frameworks of JS
- Today’s, there are several JavaScript framworks exist to do some specific work easily in which some popular front end JavaScript are – jQuery, Angular Js, React Js, Next Js, Ember Js, Vue Js, Nuxt Js etc. and some popular back end JavaScript are – Node Js, Spring boot Js, Express JS, Laravel Js, Micronaut Js, Mocha JS, Jasmine Js, Jest Js etc.
- The other JS frameworks are – Ext.js, Meteor.js, Mithril.js, Polymer.js, Aurelia.js, Backbone.js etc.
Popular JavaScript Unit Testing Frameworks
- Unit.js: It is known as an open-source assertion library running on browsers and Node.js. It is extremely compatible with other JavaScript Unit Testing frameworks like Mocha, Karma, Jasmine, QUnit, Protractor, etc. Provides the fully documented API of the assertion list.
- QUnit: It is used for both client-side and server-side JavaScript Unit Testing. This Free JavaScript testing framework is used for jQuery projects. It follows the Common JS unit testing Specification for unit testing in JavaScript. It supports the Node Long-term Support Schedule.
- Jasmine: Jasmine is the behavior-driven development framework to unit test JavaScript. It is used for testing both synchronous and asynchronous JavaScript codes. It does not require DOM and comes with an easy syntax that can be written for any test.
- Karma: Karma is an open-source productive testing environment. Easy workflow control running on the command line. Offers the freedom to write the tests with Jasmine, Mocha, and QUnit. You can run the test on real devices with easy debugging.
- Mocha: Mocha runs on Node.js and in the browser. Mocha performs asynchronous testing more simply. Provides accuracy and flexibility in reporting. Provides tremendous support for rich features such as test-specific timeouts, and JavaScript APIs.
- Jest: Facebook uses jest so far to test all the JavaScript code. It provides the ‘zero-configuration testing experience. Supports independent and non-interrupting running tests without any conflict. Do not require any other setup configuration and libraries.
- AVA: AVA is a simple JavaScript Unit Testing Framework. Tests are being run in parallel and serially. Parallel tests run without interrupting each other. This testing framework supports asynchronous testing as well. AVA uses subprocesses to run the unit test JavaScript.
0 Comments