jeffbRTC
jeffbRTC

Reputation: 2069

How to get the Original Prototype Chain on given function?

charCodeAt is a property of String.prototype so String.prototype.charCodeAt

Given below function,

const foo = "whatever".charCodeAt;

Is there any way to automatically know foo function in fact is String.prototype.charCodeAt?

I've looked everywhere. All I see is a brute force way.

Upvotes: 1

Views: 45

Answers (1)

David Knipe
David Knipe

Reputation: 3454

Not sure what you're asking, so I might not be much help. The following options may or may not be what you're looking for.

  • "whatever".charCodeAt === String.prototype.charCodeAt
  • "whatever".constructor === String
  • "whatever".__proto__ === String.prototype
  • typeof "whatever" === 'string'

Upvotes: 1

Related Questions