Passing string variable in Javascript

Sure you can. You just need to add quotes.

function test(test1) {
  console.log(typeof test1);
}
document.write("<input type="button" value="Click" id='j' onclick='test(\"abc\")'/>");

Leave a Comment