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 trialMacKenzie Santiago
5,137 PointsWhere is the explanation in the lesson plan for adding .value or .textContent outside of the parenthese?
4.2 Challenge Task - Modifying Elements:
const inputValue = document.querySelector('input').value; document.querySelector('p').textContent = inputValue;
2 Answers
Steven Parker
231,236 PointsThat's simply a shortcut for the principles demonstrated in the Change Element Attributes video. It saves a line of code and an extra variable.
What you were asking about in your previous question could also be implemented on 2 lines like this:
const myInput = document.querySelector('input');
const inputValue = myInput.value;
The concept of using the membership operator directly on the result of calling a function is illustrated in other courses, and is commonly called "chaining".