If I open this in a browser:
<!DOCTYPE html>
<html>
<head>
<title>Testing stringify</title>
</head>
<body>
<script>
var obj = {};
var arr = [];
arr.push(1,2);
alert(arr); // 1,2
Object.defineProperty(obj, "name", {
value:arr
});
alert(obj.name); // 1,2
alert(JSON.stringify(obj)); // {}
</script>
</body>
</html>
it will output what I've written in the comments. I don't understand why arr isn't included in the output JSON-string. Do I need to define some other properties on the descriptor object in defineProperty()? What am I doing wrong?