Here's a fun challenge: in #Javascript, how do you determine whether a given value is an object literal (or equivalently plain object)?
@miyuko Nope! This will break on cross-realm objects (eg. from a worker thread) and null-prototype objects
@joepie91 Pure instinct that I bet some Javascript lawyer will "well actually" me on, but:
x.__proto__ === {}.__proto__
@farhaven Not quite :) Same issue as this one: https://social.pixie.town/@joepie91/112763949440682573
@joepie91 create an error object, get the stack trace, then regexp the source code for {}
... or check that the prototype is Object. you could also use Object.getOwnPropertyDescriptors and check there isn't anything unusual
@joepie91 Object.getPrototypeOf(target) === Object.getPrototypeOf({}) ?