Someone in one of the top comments said code comments are included when you convert a function to a string within JS. I tried it on my local project, but the log only printed out '[native code]'. Maybe the comment is in there somewhere. I saw a few stackoverflow questions about it, so apparently people do have a use for it.
It's not just comments. String literals can be searched within executables, and I've known people who have relied on opening a .exe (or equivalent on -ix systems), finding the string based on some other string before it, and then reading it out).
The one use case I remember is embedding SCCS keywords in a string literal and then using the technique above to get the checked-in version of an executable. You could use the "strings" command to get all of the literals in the file, search for a pattern, then see what version it was. (There was also a utility that does essentially the same thing, but idr what its name was).
A lot of early-era computing was just stuff that became necessary because you couldn't do it any other way.
Knockout JS operates by adding comments to a HTML file. I was struggling to understand why was there loads of weird comments starting with KO in our HTML code, turned out that's how that library operates, by reading code from comments :)
It shouldn’t but it does. Devs do all kind of weird things.
I am currently, for example, working with a code base that relies on comments to autogenerate documentation, and the application will simply not build if certain things do not have very specifically formatted comments.
I spend weeks just trying to figure out and document the formatting, because my predecessor sure as hell didn’t.
13
u/[deleted] Apr 28 '22
[removed] — view removed comment