Welcome to Javascript

JavaScript pic

Articles on Introduction to JAVASCRIPT

Introduction

In web development, which consist of frontend and backend, the frontend comprising of HTML, CSS and JAVASCRIPT.  The html which portrays the content or structure, the CSS providing proper presentation while JavaScript produces the behavior functionality causing responsive interaction between the client and the website. Therefore JAVASCRIPT is called the Client-side Programming.

Embedding Javascipt

There are three format in including JavaScript namely,

  1. Inline JavaScript: This type of JavaScript code is embedded in the html document line to cause a specific behavior.

For example;

<h1 id= ‘tope’> SOLAREX IT WORLD </h1>

<button onclick = “document.getELementById(‘tope’).innerHTML=’SOLAREX’ “

This will successfully change the text of the ‘h1’ element to SOLAREX, on clicking the button element.

  • Internal JavaScript: This is similar to internal CSS pattern where a style tag is created separately in the HTML file.
  • External JavaScript: Creating an external JavaScript file where all scripts are interpreted. A script link is made in the HTML file to tell the browser to check the location for loading the script files along with the page.(Document).

Changing style attributes using JavaScript

Document.getELementById(‘tope’).style.color=”purple”

You can always change the color to any to style or css property. E.g fontsize, width, height, etc.

Variable declaration in JavaScript

A variable is a memory box where data are stored temporarily for latter use in the script.

For example. Calculate the area of a rectangle of length 40 and breadth 60.

var length=40;

var breadth=60;

var area;

area = length * breadth;

 var displayArea= document.getElementById(‘tope’).area;

Main purpose of JavaScript

  1. For changing html content
  2. For changing the style of an element
  3. For quick response in complex web algorithms, etc

Data Types

The types of data types are

  1. Integer
  2. Float
  3. String
  4. Double
  5. Boolean
  6. Array
  7. Object

 Types of Operators

  1. Assignment Operator (=)
  2. Comparative Operator (==)
  3. Identical Operator (===)
  4. Logical Operators >=, !=, || , &&, etc.

Leave a Comment

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