Skip to content

Instantly share code, notes, and snippets.

@sifat009
Created May 21, 2023 15:14
Show Gist options
  • Save sifat009/5f91e2178d85c9a4a8ad6c8a0ffc3aa2 to your computer and use it in GitHub Desktop.
Save sifat009/5f91e2178d85c9a4a8ad6c8a0ffc3aa2 to your computer and use it in GitHub Desktop.
create strange object in javascript
/**
* ✅ 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