What is the best method to create HTML with JS

Given a standard structure of things in JSON format, which of the following method would you choose to complete generating the HTML if it were to be a 2D list?

(The source of the JSON is not user input and is free from security concerns.)

Which of the following would you choose when placed inside a loop?
  • let a = document.createElement('div');Object.assign(a, {class:''....});a.innerHTML = 'xxx';
  • (backtick)<div class="${something}">${content}</div>(backtick);
  • '<div class="' + something + '">' + content + '</div>';
0 voters
5 Likes

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.