Handling weird syntax of javascript array.

Let me know if you don't like the fix. We can write similar function to handle array. But it will cause some code duplication.