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 JavaScript Functions Arrow Functions Create Functions Using Arrow Syntax

seth aruby
seth aruby
9,291 Points

What causes 'preview' of random number in console? At about 2:30 into the video.

When calling the getRandomNumber() function in the console there seems to be a 'preview' result prior to hitting enter. I noticed it in the video and was able to reproduce locally. Does anyone know what is happening here?

1 Answer

Steven Parker
Steven Parker
216,136 Points

That's a feature of the browser devtools called "Eager Evaluation". When you type an expression in the Console, the Console shows a preview of the result of that expression below your cursor. Of course, in this case since the result is random, the value will change when you finish the line and it re-evaluates it.

You can turn this feature off if you don't want it. Open the settings (gear icon) in the console and clear the checkbox labeled "Eager evaluation".