Skip to content
Advertisement

JavaScript object property containing dot [closed]

I am trying to order an array of objects with the lodash orderBy function. When the iteratees contains a dot in the middle, the orderBy does not work any more.

Here is a plunker to explain the problem better. plunker

JavaScript

Any help will be appreciated.

Thank you in advance.

Advertisement

Answer

You could create a function for the access to exotic key names.

JavaScript
JavaScript
JavaScript

A dynamic approach with a closure over key.

JavaScript
JavaScript
JavaScript

ES5

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement