Complementing the response of Mark:
For you to assign the value, you will use:
document.getElementById("idUnico").value = '<script>alert()</script>'
Already to read the value, you will use:
document.getElementById("idUnico").value
If it’s a function within value, I believe you’ll need to take it and inject it into HTML to make it available.
If your purpose is to make XSS, be more specific so we can respond more effectively.
I believe that this is not a good practice and may make it difficult to maintain its application.
I hope I’ve helped, but I believe there may be a more cohesive way to solve your problem, maybe explaining the context will help us help you.
EDIT1: The contents of the variable is a string, if you have problems using just pass the function or escape the characters. Note that value stores a string, not the JS function. An example of this, is that you could very well convert your function to Base64 and save in variable. In sequence, take the string and do the Decode to have the function cleared.
that opens a giant door to XSS Attacks, no ?
– Alex
I don’t even know...
– Francis Vagner da Luz
See here
– Alex
Maybe if I explained what you want to do with it, I could give an adequate answer
– Alex