Reflect API Methods in JavaScript
Level 5251 keystrokes
The Reflect API provides methods for interceptable JavaScript operations in a functional style.
JavaScript code
// Create an object with properties1const obj = { x: 10, y: 20 };// Reflect.has checks if property exists2console.log(Reflect.has(obj, "x"));// Reflect.get retrieves property value3console.log(Reflect.get(obj, "y"));// Reflect.set adds or updates a property4Reflect.set(obj, "z", 30);// Reflect.ownKeys returns all own keys: ['x', 'y', 'z']5console.log(Reflect.ownKeys(obj));// Reflect.deleteProperty removes a property6Reflect.deleteProperty(obj, "x");// Output the modified object7console.log(obj);// Check whether the deleted property still exists: false8console.log(Reflect.has(obj, "x"));Output
true
20
[ 'x', 'y', 'z' ]
{ y: 20, z: 30 }
falsePractice 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.
.× 11(× 11)× 11"× 10;× 8,× 7:× 2{× 1}× 1=× 1