简体   繁体   中英

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.

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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM