There is an option when you press the shortcut to render (F12 by default) to Use 3D Viewport.
The tool tip describes this option as:
When inside a 3D viewport, use layers and camera of the viewport.
What is meant by "of the viewport"? Conversely, I don't see how a Camera or View Layer could not be of the Viewport - unless it's hidden. But if you Hide an object in the Viewport, it still gets rendered. So, what does this option do? Comparing renders when it's enabled and disabled, I'm not noticing a difference. Thanks.