For me the hardest part of AppleScript is guessing what an app will let you do. You don’t have to guess. Every scriptable app ships its own dictionary, and Script Editor shows it.
Script Editor > Window > Library > double-click the app
The dictionary lists the commands and objects the app understands, grouped into suites. Most scriptable apps have at least the Standard Suite, and many add their own. There’s a Language pop-up menu as well, so you can switch the view between AppleScript and JavaScript for Automation terms. Apple’s JXA notes also mention File > Open Dictionary as another way in.
Example: you want a script that grabs the title of the front tab in Safari. Open Safari’s dictionary, look at the window and tab classes, and you’ll find the properties you need, such as the tab’s name and URL, before you write a single line. Same for Music, Mail, Finder or System Events. I’d always start here instead of copying a random snippet from a forum, because the dictionary shows what that app on your Mac supports.
The caveat: not every app is in the Library window. If a scriptable app you want isn’t there, Apple’s guide explains how to add it to the list. And if an app has no dictionary at all, it simply isn’t scriptable that way. Then you’re left with UI scripting through System Events, which clicks buttons for you and breaks easily when the app’s layout changes.
Further reading: Apple: View an app's scripting dictionary in Script Editor, Apple: Add or remove apps from the scripting dictionary