JavaScript Basics - For Beginners [Data Types in JavaScript]

What is JavaScript in Simple Term? 

JavaScript is a programming language commonly used in web development. It was originally developed by Netscape as a means to add dynamic and interactive elements to websites. Like server-side scripting languages, such as PHP and ASP, JavaScript code can be inserted anywhere within the HTML of a webpage.

javascrpit-for-beginners

Variables in JavaScript

variables are the containers to store data values.

Data Types in JavaScript

  • Number
  • String
  • Object
  • Array
  • Boolean
  • Undefined
  • Null
  • Symbol

At a very high level, There are two types of Data Types in JavaScript

1. Primitive Data Types [Number, String, Boolean, Undefined, Null, Symbol]
2. Reference Data Types [Object, Array]

Source Code 

HTML


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Javascript</title>
</head>
<body>
   <h1>Hello World!</h1>
    <script src="script.js"></script>
</body>
</html>                                                                                

JavaScript


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// JavaScript Variables

// variables are the containers to store data values.

var num1 = 87;
var num2 = 78;
console.log(num1 + num2);

// Data Types in JavaScript

//Number

var number1 = 89;
console.log(number1);

//String

var name = "Hritick";
console.log(name);

//Object

var marks = {
    Sonu: 88,
    Aniruddha: 77,
    Hritick: 78
}

console.log(marks);

//Array

var arr = [1, 2, 3, 4, 5];
console.log(arr);

console.log(arr[2]);

var arr2 = [1, 2, "Hritick", 3, 4, 5];
console.log(arr2);

console.log(arr2[2]);

//Boolean

var a = true;
var b = false;

console.log(a);
console.log(a, b);

// Undefined

//var und = undefined;
var und;
console.log(und);

//Null

var n = null;
console.log(n);

/* At a very High level, There are two types of Data Types in JavaScript

1. Primitive Data Types
2. Reference Data Types */

Post a Comment

1 Comments