Created
May 21, 2023 15:14
-
-
Save sifat009/5f91e2178d85c9a4a8ad6c8a0ffc3aa2 to your computer and use it in GitHub Desktop.
create strange object in javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* ✅ Topic: Create Strange Object in javascript 🧐 | |
* 📨 For personalized training contact: sifathaque6@gmail.com 💬 | |
*/ | |
function createStrageObject() { | |
return new Proxy( | |
{}, | |
{ | |
get(_, prop) { | |
return () => prop; | |
}, | |
}, | |
); | |
} | |
const obj = createStrageObject(); | |
console.log(obj.test()); // output: test | |
console.log(obj.hello()); // output: hello |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment