René's URL Explorer Experiment


Title: Implementing Event delegation by stankovics · Pull Request #28 · WebDevSimplified/Vanilla-JavaScript-Calculator · GitHub

Open Graph Title: Implementing Event delegation by stankovics · Pull Request #28 · WebDevSimplified/Vanilla-JavaScript-Calculator

X Title: Implementing Event delegation by stankovics · Pull Request #28 · WebDevSimplified/Vanilla-JavaScript-Calculator

Description: Event delegation will be much better option instead of forEach() on numberButtons and operationButtons. With forEach() you are creating events for all buttons. That is a bad practice. With event delegation you don't create click event for each button, just for buttons that are clicked. This is my solution: And in HTML file for each number button and operation button data-set value of number for number buttons and operation sign for operation. data-number="1" & data-operation="" For example: 1 2 ÷ Select common parent element for all buttons: const parentElement = document.querySelector('.calculator-grid'); Replace forEach on numberButtons and operationButtons with this code: parentElement.addEventListener('click', function (e) { if (e.target.closest('[data-number]')) { const btnNum = e.target.closest('[data-number]'); const selectedNumber = btnNum.getAttribute('data-number'); calculator.appendNumber(selectedNumber); calculator.updateDisplay(); } if (e.target.closest('[data-operation]')) { const btnOperation = e.target.closest('[data-operation]'); console.log(btnOperation); const selectedOperation = btnOperation.getAttribute('data-operation'); console.log(selectedOperation); calculator.chooseOperation(selectedOperation); calculator.updateDisplay(); } });

Open Graph Description: Event delegation will be much better option instead of forEach() on numberButtons and operationButtons. With forEach() you are creating events for all buttons. That is a bad practice. With event de...

X Description: Event delegation will be much better option instead of forEach() on numberButtons and operationButtons. With forEach() you are creating events for all buttons. That is a bad practice. With event de...

Opengraph URL: https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:ce0afc8c-9c7d-1028-1b90-fbb07caf1dee
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idCC0C:ADA9D:1189E64:16A767C:6B010C1F
html-safe-nonced4c63636320b9c42d24503a68f965d805e311dd6206322cbe221612de7c8e9c2
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQzBDOkFEQTlEOjExODlFNjQ6MTZBNzY3Qzo2QjAxMEMxRiIsInZpc2l0b3JfaWQiOiI3MzQzMDc2Mzk0ODczNzE5ODM5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmace3dda7d210153f286892f0bfa3fad432cc630d634b72c93591cbd7dae3f92f2c
hovercard-subject-tagpull_request:864054786
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/files
twitter:imagehttps://avatars.githubusercontent.com/u/21049691?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/21049691?s=400&v=4
og:image:altEvent delegation will be much better option instead of forEach() on numberButtons and operationButtons. With forEach() you are creating events for all buttons. That is a bad practice. With event de...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonecb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/WebDevSimplified/Vanilla-JavaScript-Calculator git https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator.git
octolytics-dimension-user_id39717099
octolytics-dimension-user_loginWebDevSimplified
octolytics-dimension-repository_id180275595
octolytics-dimension-repository_nwoWebDevSimplified/Vanilla-JavaScript-Calculator
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id180275595
octolytics-dimension-repository_network_root_nwoWebDevSimplified/Vanilla-JavaScript-Calculator
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FWebDevSimplified%2FVanilla-JavaScript-Calculator%2Fpull%2F28%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FWebDevSimplified%2FVanilla-JavaScript-Calculator%2Fpull%2F28%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=WebDevSimplified%2FVanilla-JavaScript-Calculator
Reloadhttps://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/files
Reloadhttps://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/files
Reloadhttps://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/files
WebDevSimplifiedhttps://github.com/WebDevSimplified
Vanilla-JavaScript-Calculatorhttps://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator
Codehttps://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator
Issues14 (14)https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/issues
Pull requests21 (21)https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pulls
Actionshttps://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/actions
Projectshttps://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/projects
Security and qualityhttps://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/security
Insightshttps://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pulse
Sign up for GitHub https://github.com/signup?return_to=%2FWebDevSimplified%2FVanilla-JavaScript-Calculator%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FWebDevSimplified%2FVanilla-JavaScript-Calculator%2Fissues%2Fnew%2Fchoose
stankovicshttps://github.com/stankovics
WebDevSimplified:masterhttps://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/tree/master
stankovics:masterhttps://github.com/stankovics/Vanilla-JavaScript-Calculator/tree/master
Conversation 0 https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28
Commits 5 https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/commits
Checks 0 https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/checks
Files changed https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/files
Please reload this pagehttps://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/files
Implementing Event delegation https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/files#top
Show all changes 5 commits https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/files
78b3a4b Create README.md stankovics Feb 26, 2022 https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/commits/78b3a4bc37e0a8c93a027a0540c119b6485fdbc4
f4106fe Update index.html stankovics Feb 26, 2022 https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/commits/f4106fe2e80932ff05c7b40e26e8105e26b450f2
a765528 Update script.js stankovics Feb 26, 2022 https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/commits/a76552835a6da41c878698cd58fae495104c8993
4c8c0be Update README.md stankovics Feb 27, 2022 https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/commits/4c8c0be6c3b86560cb3f0a45d928cb948be3a115
cea1a7b Update script.js stankovics Feb 27, 2022 https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/commits/cea1a7b15f39648dbe340cfa58cfc63575efc5a2
Clear filters https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/files
Please reload this pagehttps://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/files
Please reload this pagehttps://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/files
README.md https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5
index.html https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/files#diff-0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051
script.js https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/files#diff-ed3ee7e0beea2498ff3b8ca85973d122fc6fa3d585d62b5807ec034d0cf076b3
README.mdhttps://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5
View file https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/blob/cea1a7b15f39648dbe340cfa58cfc63575efc5a2/README.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/{{ revealButtonHref }}
index.htmlhttps://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/files#diff-0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051
View file https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/blob/cea1a7b15f39648dbe340cfa58cfc63575efc5a2/index.html
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/{{ revealButtonHref }}
https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/files#diff-0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051
script.jshttps://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/files#diff-ed3ee7e0beea2498ff3b8ca85973d122fc6fa3d585d62b5807ec034d0cf076b3
View file https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/blob/cea1a7b15f39648dbe340cfa58cfc63575efc5a2/script.js
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/{{ revealButtonHref }}
https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/files#diff-ed3ee7e0beea2498ff3b8ca85973d122fc6fa3d585d62b5807ec034d0cf076b3
https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/pull/28/files#diff-ed3ee7e0beea2498ff3b8ca85973d122fc6fa3d585d62b5807ec034d0cf076b3
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.