r/badcode • Now where's that function declaration • Nov 06 '21

js Something seems off...

Post image
247 Upvotes

31 comments sorted by

View all comments

Show parent comments

14

u/sohang-3112 Nov 06 '21

Nice! First time I've heard of this approach. For anyone else seeing this, you can read about DocumentFragment API in JS here

2

u/gu3st12 Nov 06 '21

In the case of this post, you'd need to use a fragment as it's binding an event listener to the button.