Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 5 bookmarklet_launcher.js #101

Open
data-scientist-ml1 opened this issue Oct 8, 2021 · 0 comments
Open

Chapter 5 bookmarklet_launcher.js #101

data-scientist-ml1 opened this issue Oct 8, 2021 · 0 comments

Comments

@data-scientist-ml1
Copy link

data-scientist-ml1 commented Oct 8, 2021

Can anyone please help me understand its code?

(function(){ if (window.myBookmarklet !== undefined){ myBookmarklet(); } else { document.body.appendChild(document.createElement('script')).src='https://127.0.0.1:8000/static/js/bookmarklet.js?r='+Math.floor(Math.random()*99999999999999999999); } })();

  1. Why we need to put function inside parenthesis? (function.....)()
  2. How browser executes the code when we put javascript tag? JavaScript:(function.....)()
  3. what is this function myBookmarklet() and when if statement will be actually executed? How will window object will have myBookmarklet property?

Please share any resources as well. Thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant