Introduction To JavaScript

History of JavaScript

According to, "JavaScript was created in 10 days in May 1995 by Brendan Eich, then working at Netscape and now of Mozilla. JavaScript was not always known as JavaScript: the original name was Mocha, a name chosen by Marc Andreessen, founder of Netscape. In September of 1995 the name was changed to LiveScript, then in December of the same year, upon receiving a trademark license from Sun, the name JavaScript was adopted. This was somewhat of a marketing move at the time, with Java being very popular around then".

JavaScript is a cross platform object oriented scripting language. It is case-sensitive and before jQuery, JavaScript was used only for client-side validation. In other words, you can say that JS was the most underrated language. In mid 2006, jQuery came and changed the whole concept of JavaScript. Nowadays, we can do all those things in server-side technology. There are so many JavaScript libraries or frameworks available. Some of them are listed below.

  1. NodeJS
  2. AngularJS
  3. ReactJS
  4. VueJS 
  5. EmberJS
  6. MeteorJS 
  7. BackboneJS 
  8. ExpressJS 
  9. WebRxJS 
  10. jQuery

First Program

Before going to datatypes in JavaScript, I am just writing a program saying "Hello world". I am using Visual Studio. If you don't have VS, you can find it here. Yon can use any editor which you want to use; you can even use Notepad as well.

Select "Empty" Project.

Add New Item --> Html Page and name it Index.html.

In index.html 

  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4.     <title>My First Program in Javascript</title>  
  5.     <meta charset="utf-8" />  
  6. </head>  
  7. <body>  
  8.     <script>  
  9.         alert("Hello world");  
  10.     </script>  
  11. </body>  
  12. </html>   



Now, we are done writing our program for "Hello world". Let's talk about data types. JavaScript is dynamic language like any other programming language, so you don't need to declare the type of variable. If I am talking about C, C++, C#, Java etc., you have to define the datatype when you declare the variable.

In C# 

  1. int firstNumber = 10;  
  2. string name = "Pramod";  
  3. bool onlyforstudent = true;   

In JavaScript 

  1. var firstNumber = 20;  
  2. var name = "Pramod";  
  3. var onlyforstudent = true;   

There are two datatypes in JavaScript.

  1. Primitive datatype
  2. Object datatype

Primitive Datatype

All types which hold immutable value are called primitive datatype like boolean,number. There are six primitive datatypes.

  • Boolean
    Boolean can have only two values - true or false.
    var onlyforstudent = true;

  • Null
    The null has only one value that is null.
    var student= null;

  • Undefined
    A variable which is declared but not assigned any value. 
    var studentDetail;

  • Number
    There is only one number type for all double and number.
    var rollNo=12;

  • String
    String is used for representing textual data.
    var name = "Pramod";

  • Symbol
    Symbol is a funtion which returns a value type symbol.
    var mySchool = Symbol();

Html Page 

  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4.     <title>My First Program in Javascript</title>  
  5.     <meta charset="utf-8" />  
  6. </head>  
  7. <body>  
  8.     <script>  
  9.         alert("Hello world");  
  10.         var onlyforstudent = true;  
  11.         console.log(onlyforstudent);  
  12.         var student = null;  
  13.         console.log(student);  
  14.         var studentDetail;  
  15.         console.log(studentDetail);  
  16.         var rollNo = 12;  
  17.         console.log(rollNo);  
  18.         var name = "Pramod";  
  19.         console.log(name);  
  20.         var mySchool = Symbol();  
  21.         typeof mySchool;  
  22.         console.log(mySchool);  
  23.         var mySchoolObj = Object(mySchool);  
  24.         typeof mySchoolObj;  
  25.         console.log(mySchoolObj);  
  26.     </script>  
  27. </body>  
  28. </html>   



Any datatype which is not primitive is Object. Object is a collection of properties. JavaScript follows object literal syntax which means a list of zero or more pairs of property names and associated values of an object enclosed with {}.

In JS, object is nothing but mapping between key and values. Functions are objects in JavaScript. The following objects are used in JavaScript.

  1. Date
  2. Array
  3. Typed Arrays
  4. Maps
  5. Sets
  6. WeakMaps
  7. WeakSets

I hope this article is helpful.