Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
23
rated 0 times [  26] [ 3]  / answers: 1 / hits: 22058  / 9 Years ago, thu, october 22, 2015, 12:00:00

I am not able to understand exactly what is difference between primitive and non primitive data types in JavaScript even it is declared using same name i.e var.


More From » oop

 Answers
115
Data Types (JavaScript):

Primary Data Types
The primary (primitive) data types are:
String, Number, Boolean

Composite Data Types
The composite (reference) data types are:
Object, Array

Special Data Types
The special data types are:
Null, Undefined


Click here for details:



  var test1 = 1;
var test2 = Something;
var test3 = true;
var test4 = {};
var test5 = new Array();
var test6 = new Date();
var test7;
var test8 = null;

alert(typeof (test1)); //number
alert(typeof (test2)); //string
alert(typeof (test3)); //boolean
alert(typeof (test4)); //object
alert(typeof (test5)); //object
alert(typeof (test6)); //object
alert(typeof (test7)); //undefined
alert(typeof (test8)); //object

[#64645] Tuesday, October 20, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
neildrews

Total Points: 166
Total Questions: 103
Total Answers: 85

Location: Moldova
Member since Sat, Aug 6, 2022
2 Years ago
neildrews questions
Fri, Feb 18, 22, 00:00, 2 Years ago
Tue, Oct 12, 21, 00:00, 3 Years ago
Tue, Mar 23, 21, 00:00, 3 Years ago
Sun, Aug 16, 20, 00:00, 4 Years ago
;