HtmlCssMonk

Getting INTRODUCED to JAVASCRIPT | Learn JavaScript

javascript, programmer, code

DESCRIPTION

JavaScript was initially created to “make web pages alive”.

JavaScript (JS) is a light-weight object-oriented programming language which is used by several websites for scripting the webpages. It is an interpreted, full-fledged programming language that enables dynamic interactivity on websites when applied to an HTML document.

javascript, js, logo

JavaScript is not related to Java in any way.

JavaScript is already running in your browser on your computer, on your tablet, and on your smart-phone.

It is free to use for everyone.

Let’s see what’s so special about JavaScript, what we can achieve with it, and what other technologies play well with it.


Why learn JavaScript

  • All popular web browsers support JavaScript as they provide built-in execution environments.
  • JavaScript follows the syntax and structure of the C programming language. Thus, it is a structured programming language.
  • JavaScript is a weakly typed language, where certain types are implicitly cast (depending on the operation).
  • JavaScript is an object-oriented programming language that uses prototypes rather than using classes for inheritance.
  • It is a light-weighted and interpreted language.
  • It is a case-sensitive language.
  • JavaScript is supportable in several operating systems including, Windows, macOS, etc.
  • It provides good control to the users over the web browsers.

Some Basic Applications of JavaScript

JavaScript is used to create interactive websites. It is mainly used for:

  • Client side validation – This is really important to verify any user input before submitting it to the server and Javascript plays an important role in validting those inputs at front-end itself.
  • Manipulating HTML Pages – Javascript helps in manipulating HTML page on the fly. This helps in adding and deleting any HTML tag very easily using javascript and modify your HTML to change its look and feel based on different devices and requirements.
  • User Notifications – You can use Javascript to raise dynamic pop-ups on the webpages to give different types of notifications to your website visitors.
  • Back-end Data Loading – Javascript provides Ajax library which helps in loading back-end data while you are doing some other processing. This really gives an amazing experience to your website visitors.
  • Presentations – JavaScript also provides 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.

What can JavaScript do ?

JavaScript can be used to modify , manipulate HTML elements.

One of many JavaScript HTML methods is getElementById(). Below given examples use an HTML element of Id = “monk” and manipulates it.

1. JavaScript Can Change HTML Content

This will change the element content (innerHTML) to “Peaceful Warrior”.

document.getElementById("demo").innerHTML = "Peaceful Warrior";

2. JavaScript Can Change HTML Styles (CSS)

change the style of an HTML element.

document.getElementById("monk").style.fontSize = "45px";

3. JavaScript Can Hide/Show HTML Elements

This will hide an HTML element of Id = “monk”.

document.getElementById("monk").style.display = "none";

Advantages of JavaScript

Some merits of using JavaScript are –

  • Less server interaction − You can validate user input before sending the page off to the server. This saves server traffic, which means less load on your server.
  • Immediate feedback to the visitors − They don’t have to wait for a page reload to see if they have forgotten to enter something.
  • Increased interactivity − You can create interfaces that react when the user hovers over them with a mouse or activates them via the keyboard.
  • Richer interfaces − You can use JavaScript to include such items as drag-and-drop components and sliders to give a Rich Interface to your site visitors.

Limitations of JavaScript

We cannot treat JavaScript as a full-fledged programming language. It lacks the following important features −

  • Client-side JavaScript does not allow the reading or writing of files. This has been kept for security reason.
  • JavaScript cannot be used for networking applications because there is no such support available.
  • JavaScript doesn’t have any multi-threading or multiprocessor capabilities.

What makes JS unique ?

There are at least 3 great things about JavaScript:

  • Full integration with HTML/CSS.
  • Simple things are done simply.
  • Support by all major browsers and enabled by default.

Next topic – Where to write JS


Leave a Comment

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