Is it possible to override only a part of another plugin’s / theme’s js (asset) file?

Unfortunately no, you can dequeue the file as the other questions answer suggests and enqueue your own version, otherwise you’d need to load it and then try to modify the loaded code at runtime, which is almost always not feasible.

Monkeypatching might be a solution, assuming your code runs before theirs does, but is loaded after there’s. But that is rarely possible. We’re talking 1 in a thousand chance. This is where the original code is loaded, but before it’s ran, your code swaps out functions and data structures. e.g. removing a jQuery plugin then putting your own in its place. This isn’t possible in most situations though. Note that monkeypatching is widely considered a kludge, is not a longterm solution, and can cause issues on its own.

It’s also possible that the author of the original file wanted their code to be extensible and built it that way. But this is unlikely. You would need to read the code to find out on a case by case basis.

Eitherway there is no WP based solution for this. To continue down this avenue you will need to ask on stackoverflow, specifically how to override functionality in a javascript file that’s already been loaded using a newly loaded javascript file. For most situations the answer to this is that you cannot. For those rare situations where you can force it, you’ll need advanced javascript knowledge.