Guest User

Untitled

a guest
May 26th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width">
  6. <title>JS Bin</title>
  7. </head>
  8. <body>
  9.  
  10. <script id="jsbin-javascript">
  11. var a = {
  12. counter: 0,
  13. b: {
  14. c: {
  15. d: function() {
  16. for (var i=0;i<5;i++) {
  17. setTimeout(function() {
  18. console.log(i, ++this.counter);
  19. }, 500);
  20. }
  21. }
  22. }
  23. }
  24. };
  25.  
  26. a.b.c.d();
  27. </script>
  28.  
  29.  
  30.  
  31. <script id="jsbin-source-javascript" type="text/javascript">var a = {
  32. counter: 0,
  33. b: {
  34. c: {
  35. d: function() {
  36. for (var i=0;i<5;i++) {
  37. setTimeout(function() {
  38. console.log(i, ++this.counter);
  39. }, 500);
  40. }
  41. }
  42. }
  43. }
  44. };
  45.  
  46. a.b.c.d();
  47. </script></body>
  48. </html>
Add Comment
Please, Sign In to add comment