8 ms·
This is a counter example, super simple, elegant and clear at a glance let count = 1; <button onclick={count++} $mount='#App'> count is {count} </button>;
by theajack 3y ago
This is a counter example, super simple, elegant and clear at a glance
let count = 1;
<button onclick={count++} $mount='#App'>
count is {count}
</button>;
- jfengel 3y agoIt's not at all clear to me. I don't know what $mount is for; the $ isn't standard JS or HTML. If it means "stick this thing in that thing over there", that sounds like it will produce spaghetti in any nontrivial example. The onclick isn't standard Javascript, since onclick generally takes a function rather than a piece of code. Since it takes no arguments, you can't even tell if it's a left-click or a right-click. Writing counter++ over ()=>counter++ is a very minor convenience with a significant expressive cost And a language nitpick: it's just an "example". A "counter-example" is a thing that disproves an assertion. In this context it implies that you're providing a piece of code that shows that it doesn't work.
- theajack 3y agoThank you for your review. This example is just shorthand. You can also use standard js syntax completely: ``` let count = 1; document.getElementById('App').appencChild( <button onclick={event=>{count++}}> count is {count} </button> ); ```
- theajack 3y agoCounter Example means Counter Program -- Increase count value on button click. Sorry for my poor English
- jfengel 3y agoWhoops. I should have figured that out. I apologize.
- deleted 3y ago[deleted]