When you are scripting in photoshop, you will notice not all operations you use in photoshop are found in the scripting reference. These operations can be used through the action manager (if the action is recordable).
To help you with the actions, you can install a plugin called ScriptingListener. This plugin will record every action you do in photoshop and output them in two txt files. These files will be saved on your desktop and are called ScriptingListenerJS.log and ScriptingListenerVB.log. ScriptingListenerJS.log contains all recorded actions translated to javascript. ScriptingListenerVB.log contains the same but translated to visual basic script.
Every action in these files are seperated by // ============. When you do a selection by color range for example, this action can be found in ScriptingListenerJS.log and looks like this:
You can then use this code directly in your other photoshop js scripts.