Files with the type js are usually readable source code text files written in JavaScript, and you can open that JavaScript file with a text editor (TextEdit or the free tier of BBEdit in the GUI, or with various of the command-line editors provided within macOS), and look at the contents of the file.
As a general rule, actual malware doesn’t contain the word malware.
When JavaScript is invoked via Safari as is common, Safari runs the JavaScript in a sandbox, which is intended to contain and isolate any malicious JavaScript.
The Apple built-in anti-malware — defenses which are vastly more involved and pervasive than what most folks might realize — does pretty well. Details: Apple Platform Security - Apple Support
The add-on anti-malware around doesn’t do appreciably better than the built-in, sometimes does vastly worse, tends to be unnecessarily noisy, and too many of the add-on security apps themselves are increasingly difficult to distinguish from actual malware, whether in terms of the apps’ effects on the system, or those apps that have been caught collecting and re-selling personally-identified metadata. (One of the better-known anti-malware app providers was recently fined for that, too.)
Most of the malware around these days for macOS is license-cracking apps, cracked apps (which are not only license-cracked, but with added malware), various stuff from torrents, and free apps (a mix of malware junk and adware), and the sorts of stuff you either have to sign yourself, or have to override Gatekeeper (part of the built-in anti-malware) to install it.
Apps acquired from the app store and directly from vendor websites are Apple- or developer-signed, so read the fine print and the data privacy statements there.
Phishing and other non-malware attacks are widespread. I’ve been getting some spectacularly well done AT&T phishes lately, and various folks around here are getting caught by attacks against password re-use.
If you are actually worth directly targeting, then there are other conversations to be had.
Run Safety Check: How Safety Check on iPhone works to keep you safe - Apple Support
Some more reading: Effective defenses against malware and other threats - Apple Community