In terms of being object oriented, you’d want to create a separate JS file for a thing that you might want to use or interact with in another part of your application.
Just as an example – maybe you create a really snappy flyout menu. You might say to yourself, “Self, I bet that we’re going to have menus on some other new pages that we add to this website.”
“Darn, Self,” you’d reply, “I bet you’re right. Let’s do the smart thing and but the behavior of this flyout menu in its own file so we can include it in any page you want.” Then you might give yourself a high five.
Sorry. It’s a Saturday morning and I haven’t finished my coffee yet.