- JS is dynamically coded programming language
- JS is popularly used as a scripting language for web browsers(will surely explain this point)
- JS is a prototype-based programming language
- JS uses function-based scoping
Above were some features of JS which makes it such a versatile language. You will find JS today everywhere. It’s quite impossible and difficult to make a webpage without JS. This webpage alone will use many JS scripts to show you an interactive webpage. Hence, JS today is one of the crucial technologies used to make a web application.
In the last paragraph, you must have seen the phrase in bold which tells JS scripts. Any JS file is called a ‘script’ as it is a scripting language and also dynamically coded. A JS script has the power to actually interact with the database also, but not as efficiently as Django, PHP, Java or any other such frameworks and languages. Hence, this proves the versatility of this precious tools.
Now, tackle the point, if JS does not have a compiler, how does it gets compiled and how do you see its effects on the browser? Well, nowadays each and every modern browser, Internet Explorer too, has a JS engine which runs the JS Scripts associated with the webpage. The engine comes in-built with all the browser today.
As JS is a programming language, it must give some output right? But, where does this output is shown? To your astonishment, it gets displayed on your browser only if at all the programmers logs it. All you have to is tap, Ctrl + Shift + I, if you are using Google Chrome, or you can just right-click and click ‘Inspect Element’/’Inspect’. You’ll find that in on the same webpage, a different partition has opened which somewhat looks like this:
The orientation must be vertical/horizontal, depending on the default option. By default, the Element tab will open, you click on the Console tab, that’s what we are devoted on for now. It would be empty if you have opened on the new tab, but if you have opened on this webpage then surely there would be some text on it. Those can be errors or outputs, depending on the scripts.
We all have at some point of time has seen a dialogue box pop up on while filling a form which says generally “You have some unsaved changes. Are you sure you want to leave this page?”, this is done by the following command
You’ll find something like below:
This how an alert is raised.
JS can do many interactive things like it can make a menu dropdown when the mouse hovers on it or it when clicked. Also ever seen the images on Flipkart, Amazon IN and many other e-commerce pages? You may have seen the images in a constant slideshow after some interval. Well, this my friend is doing of JS. JS provides pre-defined functions to attain this type of transition. Also, the bullets underneath the picture going black or grey is also doing of JS. The 5-10 line code of the slideshow may be very overwhelming for a beginner, hence, it is better we leave it for now.
JS Frameworks and Libraries
It is a JS framework maintained by Google. This is an open-source framework and thus, the FLOSS community maintains it. Nowadays, AngularJS is not used and is termed as obsolete though. But still, people use it in many of their projects. AngularJS has their new version as Angular 2 and Angular 2+. There are many versions of Angular and the latest stable version is Angular 6. Angular is very concise, that means, code taking around 10-15 line in JS will take around 5 -7 lines in Angular. You can try Angular by reading their tutorials. (the best way) Or you can directly search for the best tutorial you want to do.
It is basically a library and is maintained by Facebook and the open-source community. ReactJS is used to build user interfaces and interactive web applications. You can try and read about React more in their documentation.
jQuery is by far the fastest way to learn a JS library. It has very easy-to-use pre-defined methods. Hence, to try jQuery you got to know the basics of AJAX. The documentation is quite daunting, so, my preference will be this great life-saver by W3Schools. But if you want to go for the documentation, please be my guest.
Vue is known as the framework which can be incrementally adoptable, by this it means that any application which uses other frameworks of JS is simplified by Vue. Vue is again an open-source framework and can be used by anyone. It was built to organise and make web development easy. Nowadays, Vue is very widely used and why not? It makes development easy and fast. Again, want to try Vue, go to the documentation at once!
There are many, many and many frameworks and libraries like these of JS. But, to be concise and small I just added these four very popular frameworks and libraries. It is totally on your own conscience what you want to try and work upon.
Till then this “thegeekbong” signing off.
Thank you for reading this blog and also please share if you like it.
May you have a blessed day ahead.