Non-enumerable property:
Objects can have properties that don't show up when iterated through the particular object using Object.keys() or for...in loop.Those type of properties are called as non-enumerable properties.
To create a non-enumerable property we have to use
Object.defineProperty() method. This a special method to create non-enumerable properties in an object.
e.g
Object.defineProperty(person, 'salary',{
value : '80,000$',
enumerable: false
})
Enumerable property:
An enumerable property in JavaScript means that a property can be viewed if it is iterated using the for…in loop or Object.keys() method. All the properties which are created by simple assignment or property initializer are enumerable by default
e.g:-
const student = {
registration: '12342',
name: 'Sandeep',
age: 27,
marks: 98
};
// prints all the keys in student object
for (const key in student) {
console.log(key);
}