I know that we can truncate an array like (not sure it is the best way!)
var person = ["John", "Doe", 50, "blue"]
person = [];
now can you please let me know how I can truncate an object?
var person = {
firstName:"John",
lastName:"Doe",
age:50,
eyeColor:"blue"
};
Does some thing like this work?
var person = {
firstName:"",
lastName:"",
age:,
eyeColor:""
};
is there any better and faster way to do this?
person.firstNamewill beundefinednow, doesn't throw an error nor breaks your program if you call it. If you want to reassign values, you can just add them like beforeperson.firstName = 'foo';if (person.firstName)which will be false either it's null or undefined