I have JS object A like:
{ Name, NameFilter, NameType, ..., Desc, DescName, DescType, ... }
I want to build new object B by next rule:
If A contains field AbcFilter, then B.Abc = { value: A.Abc, filter: A.AbcFilter, type: A.AbcType} for each AbcFilter in A.
In other words, I want to iterate over the members of JS object and get only members, which name contains any string and get the field value by it’s string name.
Just iterate normally and check whether the property name contains
'Filter':Of course this works only under the assumption that
'Filter'is not contained in other property names.Reference:
String.prototype.indexOf,String.prototype.substr