Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Eng Seng Heah
Eng Seng Heah
17,106 Points

Why do we need a const referral ?

The click event works fine even without defining const, what is it for?

Amrit Pandey
Amrit Pandey
17,595 Points

I am not sure what is meant by const referral. But if you are saying that click handling function is treated as a constant then yeah, it is to make sure that handling function is not altered in anyway.

1 Answer

Steven Parker
Steven Parker
220,450 Points

Are you implicitly creating a global?

If you mean you leave off "const" where a variable is created, that causes the variable to be created as a global instead of a local constant. The code might work, but it's considered bad practice. And if you were running in "strict" mode it would cause an error and not be allowed at all.