silentmatt/expr-eval

Access object properties using brackets

coco-super opened this issue · 2 comments

Use the latest version and write the following code:
Parser.evaluate('in1["key"]', { in1: { key: 'value' } });

I expect the above code to output "value", but got undefined

Can you spare some time to have a look? Thank you. @silentmatt

I try to find answers in other issues. Find similar problems, but this is not what I want. #114

export function arrayIndex(array, index) {

The above code is modified as:

export function arrayIndex(array, index) {
  if (Array.isArray(array)) {
    return array[index | 0];
  }
  return array[index];
}

Then the world will be peaceful.