Would like to maintain a map/hash of DOM objects. Can they serve as key objects? If not, what are the alternatives, please? If there are better ways – kindly enlist them as well.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can put anything as the key, but before actual use it is always converted to string, and that string is used as a key.
So, if you look at what
domObject.toString()produces, you see it is not a good candidate. If all of your dom objects have an id, you could use that id.If not, and you still desperately need a key based on DOM object, you probably could do with using, for example,
_counterattribute with automatic counter in background putting new unique value in a DOM object if_counteris not yet present.