Objects are one of the core workhorses of the JavaScript language, and something you will use all the time. They are an extremely dynamic and flexible data type, and you can add and remove things from them with ease.
var user = {
first_name: "John",
last_name: "Smith",
age: "38",
department: "Software"
};
console.log(user);
console.log(Object.keys(user).length);
delete user.last_name;
console.log(user);
console.log(Object.keys(user).length);
Solution
Objects are one of the core workhorses of the JavaScript language, and something you will use all the time. They are an extremely dynamic and flexible data type, and you can add and remove things from them with ease.
Output of the above code:
need an explanation for this answer? contact us directly to get an explanation for this answer{ first_name: 'John', last_name: 'Smith', age: '38', department: 'Software' } 4 { first_name: 'John', age: '38', department: 'Software' }