View difference between Paste ID: W2c3tU84 and EWvpdGcE
SHOW: | | - or go back to the newest paste.
1-
//This
1+
//The real difference is when you add functions into the mix, lets say you want to perform an operation on the data.
2
//This could be a simple as turning it into a format or saving it to the server. The thing is, it is a lot easier when
3
//You use classes as data Models.
4
function Foo(a, b){
5
	var self = this;
6
	
7
	self.a = a;
8
	self.b = b;
9
10
	self.turnIntoFormat = function(){
11-
//Is no different from
11+
		return a + ": " + b;
12
	};
13
}
14
15-
		"b": "bb"
15+
16
17
//VS this, which is easier? 
18
var data = [
19-
		"b": "bb"
19+
20
		"a": "a",
21-
];
21+
		"b": "bb",
22
                turnInfoFormat: function(){
23-
//Which is no different from 
23+
			return a + ": " + b;
24-
var JSONString = '[ { "a": "a", "b": "bb" }, { "a": "aa", "b": "bb" } ]';
24+
		};
25-
var data = $parseJSON(JSONString);
25+
26
	{
27-
/*
27+
28-
The Only difference is how you make the data
28+
		"b": "bb",
29-
*/
29+
                turnInfoFormat: function(){
30
			return a + ": " + b;
31
		};
32
	}
33
];