can someone please explain to me what “this” refers to in “” and why that is? For context, “result” is just an array with some strings. This is a code I saw in a youtube tutorial for making an autocomplete searchbox (this video, around 20 minutes: https://www.youtube.com/watch?v=pdyFf1ugVfk)
function display(result) {
const content = result.map((list) => {
//not sure how 'this' works here below
return "<li onclick=selectInput(this)>" + list + "</li>";
});
results.innerHTML = "<ul>" + content.join("") + "</ul>";
}
function selectInput(list) {
inputBox.value = list.innerHTML;
results.innerHTML = "";
}
New contributor
CasualGamer20 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.