const object = {
prop1: 'value1'
};
let i = null;
console.time('typeof');
i = 0;
do {
i++;
if (typeof object.prop1 !== "undefined") {
// your code here
}
}
while (i < 10e6);
console.timeEnd('typeof');
console.time('hasOwnProperty');
i = 0;
do {
i++;
if (object.hasOwnProperty('prop1')) {
// your code here
}
}
while (i < 10e6);
console.timeEnd('hasOwnProperty');