0

I am trying to manually copy some native code into our application to improve compatibility with Internet Explorer. From the Chrome console:

[].find.toString();

Outputs:

"function find() { [native code] }"

I want to put into my application:

Array.prototype.find = "native code here";

So we can use functions like these that aren't supported in Internet Explorer. Any ideas?

wayofthefuture
  • 8,339
  • 7
  • 36
  • 53
  • You can't. That code depends on the browser. Instead you can use helpers like jQuery or Modernizer or similar libraries which provides fallback/polyfills – Shaik Mahaboob Basha Feb 16 '17 at 04:53
  • 1
    In this context, `[native code]` means native to the browser, which might be anything (maybe C++), but probably isn't ECMAScript. If you're looking for a [*polyfill for Array.prototype.find*](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/find#Polyfill), see [*MDN*](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/find#Polyfill). – RobG Feb 16 '17 at 05:17

2 Answers2

1

the [native code] are stored in browser, they are even not JavaScript. Engine may take control when find() be called.

Instead, You should Search Array.find shim In Google. https://www.google.com/#newwindow=1&safe=off&q=Array.find+shim

XiaoChi
  • 369
  • 4
  • 4
  • Can I just write my own find function that performs the same task? – wayofthefuture Feb 16 '17 at 05:15
  • 1
    See [*MDN*](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/find#Polyfill), the polyfills there try to implement the ECMA-262 algorithm as closely as they can using POJS. – RobG Feb 16 '17 at 05:20
  • @wayofthefuture of course. Only when you think your code is bug free. – XiaoChi Feb 16 '17 at 05:20
  • Your recommendation led me to this: https://www.npmjs.com/package/es6-shim. Very nice find and very awesome. Thanks. – wayofthefuture Feb 16 '17 at 21:33
0

I don't really know where you could find the source code for JS functions, but you could use Modernizr for new functionalities (there are things called snippets that might help you).

user218046
  • 623
  • 6
  • 20