Tuesday, December 12, 2017

Intro to JavaScript - Day 16

JavaScript is one of the main 3 languages that a developer should know.
  1. HTML
  2. CSS
  3. JavaScript
JavaScript is like a programming language in Web development. We can make movements & graphical (Dynamic Pages) movement in a webpage using JS. 
JS is a lightweight, more easy to learn & user friendly.

JavaScript was first known as LiveScript / ECMA Script, but Netscape changed its name to JavaScript. 

Following are some characterestics of JS

  • JavaScript is a lightweight, interpreted programming language.
  • Designed for creating network-centric applications.
  • Complementary to and integrated with Java.
  • Complementary to and integrated with HTML.
  • Open and cross-platform
We use JS while check whether the user entered a valid e-mail address in a form.
If and only if the user entered valid entries only JS starts to execute the code & submit the values to the Web Server.

Advantages of JavaScript
  • 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.
  • Less server interaction − We can validate the entries of users before they submitted to the Servers. This will reduce the traffic to the web server. 
  • Immediate feedback to the visitors − If users forget to submit any required info JS will tell them to submit.
  • Increased interactivity − When user take the mouse cursor near JS coded gadget it will react immediately.
Type of Inserting JavaScript in HTML

You can add JavaScript in 
  1. <body> Tag
  2. <head> Tag
  3. In both body & head Tag

Inserting External JavaScript

You can insert JavaScript externally as you insert CSS

<script src="myScript.js"></script>

You have to replace the myScript.js with your external JavaScript path.


Different types of JavaScript Display Possibilities

into an HTML element, using .innerHTML
into the HTML output using document.write()
into an alert box, using window.alert()
into the browser console, using console.log()

JavaScript accepts both double and single quotes:

Here, "demo" is name of ID which will be call in a HTML page...
Don't worry about it..

document.getElementById("demo").style.fontColor = "Brown";

document.getElementById('demo').style.fontColor = 'Brown';

JavaScript takes both " " and ' ' as same... So, no  problem when typing....

Advantages of Using External JavaScript 
  • Easy to read the code 
  • Cached Script codes will be stored in browser..So loading would be faster
  • Seperates HTML and script code
Nowadays JavaScript Version 5 & Version 6 are used. [ ECMA 5 & ECMA 6]

No comments:

Post a Comment