r/ProgrammerHumor • • Aug 26 '20

Python goes brrrr

Post image
59.2k Upvotes

789 comments sorted by

View all comments

Show parent comments

2

u/[deleted] Aug 26 '20

I tried this with class Foobar{}; console.log(""+new Foobar()) in Firefox dev console, but that just gave me [object Object]. So it might be the built-in type of the object.

1

u/DeeSnow97 Aug 26 '20

It's actually an internal property that most JS classes don't modify, but there is a way to access it:

class Testing {}
Testing.prototype[Symbol.toStringTag] = "';DROP TABLE classes--"
console.log("robert" + new Testing())

This will log robert[object ';DROP TABLE classes--] to the console