News for hackers. Stuff that matters.
Re:Show HN: A TO-DO app that fits inside a single tweet by rukshn on Wednesday December 23, 2020 @03:32AM (#25515656)
Awesome What are the $ and H, is it some sort of JQuery? Can you explain :)
Re:Show HN: A TO-DO app that fits inside a single tweet by xem on Wednesday December 23, 2020 @08:20AM (#25517319)
The "ungolfed" code looks like this:

<input id=i> <a onclick='u.innerHTML+="<li onclick=innerHTML=innerHTML.strike()>"+i.value'>+ <a onclick=u.innerHTML="">X</a> <ol id=u>

There are 4 occurrences of "innerHTML" and 3 occurrences of " onclick='" so I replaced those two substrings with H and o.

The whole HTML is rendered using an ES6 template literal (document.write(` ... `))

Everytime a ${H} or a ${o} is present in the template, the value of H or o is copied here.

It's a native feature of JS since ES6.

Besides that, the second <a> implicitly closes the first <a>, so no need to use </a>. The id's are global, that's why we can access i.value or u.innerHTML directly. In onclick, "this" (the current element) is implicit. Finally, the strikethrough is done using the (deprecated but still working) .strike() String method.