When I access the lib.businessUnitExpr.embedbusinessUnit($) gives me a comparator undefined error.
But when I access lib.businessUnitExpr.embedbusinessUnit1($) then it is able to identify the comparator
The problem is occurring because you use brackets inside the function and try to access “comparator” with this keyword which not anymore refers to the root elements, but one scope above, which in this sample is the function scope.
When you tried to access ‘comparator’ from the inside extend function, what happened in the background is that the compiler attempted to search for ‘comparator’ on the 2nd scope, In which didn’t found the element.
If you want to extend the element with a different name from the specified you can use sl.zipObject function. Use this one: x.extend(sl.zipObject(["Demo"],[this.comparator[0]]))
This will work because it is not created a new score.