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.

  Laravel update multiple rows with different values

1st : Number

5
575
-5784
523.25

2nd : String

"Hi angularking"
"websitename:\nmy first website is Pakainfo.com"

3rd : Boolean

true
false

4th : Array

[9,8,2,5,6,0,6,2,4,5]
[]
["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.

  Angular 6 Animation Tutorial with Examples

[9,6,3,8,1,4,5,7,8,9,9,2,5,0,2,5,8,9]

Example of array.

{"salesordername":"virat kohali"}

Example of object.

[
  {"salesuser_id":1035,"username":"jonash"},
  {"salesuser_id":2087,"username":"deepakful"}
]

Example : array of objects.

{
  "languages": 
    [
      {"langid":9852,"langname":"magento"},
      {"langid":9853,"langname":"laravel"}
    ],
  "cources":
    [
      {"coid":8758,"coursename":"MCA"},
      {"coid":8789,"coursename":"BCA"}
    ]
}

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:

  Simple LocalStorage SessionStorage using JavaScript

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

Leave a Reply

avatar
  Subscribe  
Notify of