I've lately read a lot about JSON and JavaScript object. But I become more and more confused, couse to me, they quite often look the same.
I have created an JavaScript class which I instantiate to an object like this:
function Person(Name, Lastname, Age, sGender)
{
this.Name = Name;
this.Lastname = Lastname;
this.Age = Age;
this.sGender = sGender;
}
var person = new Person(
$('#PersonName').val(),
$('#PersonLastName').val(),
$('#PersonLastName').val(),
$('#PersonAge').val(),
$("#gender input[type='radio']:checked").val()
);
The #PersonName etc. are from my HTML input boxes. And at this part I know what it is that I'm doing.
But then I read about a simpler way of creating an object, so I gave it a go:
var oPerson =
{
"Name": $('#PersonName').val(),
"Lastname": $('#PersonLastName').val(),
"Age": $('#PersonAge').val(),
"sGender": $("#gender input[type='radio']:checked").val()
}
aPeople.push(oPerson);
return oPerson;
But now I'm just really confused about what the code above is. Is this JSON or just a JavaScript object?
I hope that some of you bright minds can shed some light on this for me. :)