I have this JavaScript function:
function test() {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState==4 && xhr.status==200) {
var obj = JSON.parse(xhr.responseText);
document.title = obj.page_title;
}
}
xhr.open("GET", "title.php", true); xhr.send();
}
My question is what the difference between:
obj.page_title
and obj["page_title"]
they all work fine to me and return the same value.