javascript objects vs arrays vs JSON Data Types

javascript objects vs arrays vs JSON Data Types

Today, We want to share with you javascript objects vs arrays vs JSON Data Types.
In this post we will show you JavaScript has several list data types: javascript objects vs arrays vs JSON, hear for Understanding Data Types in JavaScript we will give you demo and example for implement.
In this post, we will learn about JavaScript data types and data structures with an example.

1st : Number


2nd : String

"Hi angularking"
"websitename:\nmy first website is"

3rd : Boolean


4th : Array

["j", "a", 9898]
["j", "a", 9898, [6,7,8,9,5,2,1]]

5th : Object

{n: 10}
{salesorderlist: [9,9,7,4,8,4,0,4,0,2], studlist: [9,8,5,6,8,9,8,5,6,2,0]}
{myinfo: {username: 'admin', age: 50}, yourinfo: {yname: 'userfaran', age: 58}}

simple You use the special char{ braces } (curly braces)to declare(init) an object literal in javascript.
and then second things , You use the special char [ square brackets ] (square braces) to declare(init) an array literal in javascript.

Objects are list of collections of key index name value(Like “name”:”adminnglivefree”) pairs.
JSON is a subset-of-the-object literal notation of JavaScript.

Example of an array of strings in javascript:

var a = [ "virat", "yuvraj", "dhoni" ];

Example of a simple object of players in javascript :

var playerObject = {
    playername: 'yashraj',
    playerage: 29,
    playerhometown: 'kalavad'        

JSON is a simple data representation of the data structure,
It is not an any object data or an array data.


Example of array.

{"salesordername":"virat kohali"}

Example of object.


Example : array of objects.


difference between json array and json object

simple meaning of JSON object is a single item value whereas list of JSON array
(it can be collection of values),and it is a data collection of objects.

JSON object : 

var docters = {drfirstusername: 'dhameliyaravi', usersirname: 'M'};

JSON array: 

var docters = [{drfirstusername: 'dhameliyaravi', usersirname: 'M'}, {drfirstusername: 'Quora', usersirname: ''}];

//Example of  JSON:
{ "profname": "parag shukla" }

//Example of  Object literal:
var objectname= { profname: "parag shukla" };

Invalid Json Example

//Example of Invalid JSON:
{ "profname": 'parag shukla' }

//Example of Invalid JSON:
{ "profname": 0xFF }

Basic Note :

JSON is limited and (Data structure functionality) in that it cannot any store functions or
The only values list of data types:

1st : objects (literals)
2nd : arrays
3rd : numbers
4th : booleans
5th : strings
6th : nulls

Related FAQ

Here are some more FAQ related to this Article:

  1.   How to Write PHP Code in Laravel Blade?
  2.   html visitor counter source code using PHP
  3.   jquery radio button selected event
  4.   Simple CSS Star Rating plugin
  5.   Laravel 5.5 - Get Last Inserted ID With Example
  6.   Paypal Payment Gateway Integration using Java
  7.   MongoDB CRUD Tutorial With Example From Scratch
  8.   Allow Only Numbers in TextBox Windows Forms using regular expression
  9.   jQuery Check Uncheck All Checkbox Examples
  10.   Google 1 share price today