Say I have a JSON object
var student = {name: "Anil", Age: 27};
student.Age = 30; // I want to restrict this code.
Please help me to understand, how can we make JSON object read only type.
Say I have a JSON object
var student = {name: "Anil", Age: 27};
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.


HiAnil,
For making object as read-only you can use

Object.keys(obj).length === 0 && obj.constructor === Object
pradip makavanaPosted Aug 6, 2016, 3:12 AM
Suthish NairPosted Aug 3, 2016, 3:43 AM