Advertisement
dhshin

callable object

Jun 26th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function my_func() { console.log(1); }
  2. // let my_func = {};
  3.  
  4. my_func.x = -1;
  5. my_func.y = 100;
  6.  
  7. console.log(my_func.x); // -1
  8.  
  9. delete my_func.x;
  10.  
  11. for(let key in my_func) {
  12.   console.log(key, my_func[key]);
  13. }
  14. // "y" 100
  15.  
  16. my_func(); // prints 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement