Discussion:
ECMA Version for TDI v7.1.1? - Trying to use Array.filter logic
(too old to reply)
Barry Evans
2019-11-25 15:39:50 UTC
Permalink
What is the ECMA Script version supported by TDI 7.1.1?

I wrote a function that used Array.filter() logic but was disappointed to find that when I ported the function to TDI I get:
java.lang.Exception: Error calling method 'filter(Function)' on an object of type 'Array [JavaScript Object]'

ref. https://www.w3schools.com/jsref/jsref_filter.asp Filter was introduced in ECMA v. 5

Since I tend to write small functions out on http://js.do and then port to TDI - is there a safe ECMA version to stick with when looking at JS features?


Any TDI friendly alternative to remove given values from an Array?
Eddie Hartman
2019-11-25 22:34:22 UTC
Permalink
The IBM JS engine is a bit of a hybrid. You have some E5 functionality - like JSON support - but not all. Plus you have the bridge to Java, as well as TDI-related extensions like for-loops for Java collections, JS Objects and arrays. Note that for-loop for Java arrays returns member items, while for JS arrays you getting the index.

You can of course extend the Arrays prototype. But you'll have to craft your own filter logic

/Eddie
Barry Evans
2019-11-26 00:38:38 UTC
Permalink
Thanks Eddie -
I extended the Arrays prototype with a contains() method and then used Java's HashMap to arrive at a new solution.
Loading...