Object.hasOwn in JavaScript
Level 3125 keystrokes
Object.hasOwn() checks if an object has a specific property as its own (not inherited).
JavaScript code
// Create an object with two properties1const obj = { name: "Alice", age: 30 };// hasOwn returns true for own property "name"2console.log(Object.hasOwn(obj, "name"));// hasOwn returns false for inherited "toString" method3console.log(Object.hasOwn(obj, "toString"));Output
true false
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this JavaScript code and how often they appear.
"× 6.× 4(× 4)× 4,× 3;× 3:× 2{× 1}× 1=× 1