Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialStephanie De La Melena
Full Stack JavaScript Techdegree Graduate 14,578 PointsWhat does the "blur" input do in the emailInput.addEventListener. What do the capture strings do?(reformatting phone#)
Following along with the video, I am insure what blur means:
emailInput.addEventListener("blur", e => {
e.target.value = formatTelephone(e.target.value)
});
and I also don't know when you would use the capture groups- is it only used when grouping something together?
return text.replace(regex, '($1) $(2-$3)')
1 Answer
Steven Parker
231,236 Points"Blur" is the opposite of "focus". It's a bit of a funny name, but it's short. You might think of it as "losing-focus", which is perhaps a better way to describe when it happens. For more details, see this MDN page.
And capture groups are useful when you want to use pieces of the matched string when building new strings (possibly for replacements). This should become more clear with additional examples, which you should see in the lessons ahead. Meanwhile, here's an MDN page that provides a couple of examples you can play with.