How to pass a component to a javascript function?

Here is another reply to the same question with another use case: I created javascript functions getSelectionPosition(placeHolderText) and setSelectionPosition(placeHolderText, selStart, selEnd).

I used the placeholder property to identify the textbox. This is the definition of the function:

# Python
sel_start, sel_end = self.call_js('getSelectionPosition', 'unique text in the placeholder')

// javascript
function getSelectionPosition(placeHolderText) {
  element = $('[placeholder="' + placeHolderText + '"]');
  return [element.prop("selectionStart"), element.prop("selectionEnd")];
}

It would be nicer if I could do:

# Python
sel_start, sel_end = self.call_js('getSelectionPosition', self.tex_tbox_1)

// javascript
function getSelectionPosition(element) {
  return [element.prop("selectionStart"), element.prop("selectionEnd")];
}