Accessing fields/data from a lookup field
I'm not sure I understood exactly what you try to access, but pretty much every entity in civicrm is accessible via an API, and you can easily use it from javascript.

https://docs.civicrm.org/dev/en/latest/api/interfaces/

you can use the api explorer and experiment, once you have succeeded fetching the data, you can copy paste the generated javascript code and add it in your own extension, or wherever you want to put your custom code.