paint-brush
Learn How to Pass Arguments to Events in Svelte in Just 4 Stepsby@smpnjn
233 reads

Learn How to Pass Arguments to Events in Svelte in Just 4 Steps

by Johnny Simpson2mMay 15th, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

A common issue with Svelte events is adding **arguments** to functions called within them. This also works for events, so if you want to pass the event or `e` object to your function, you could do something like this. Instead, we need to change our event to contain a function instead: addToCounter. This is a function, which returns the value produced by `addToCounter` - so instead, you need to use a function to add arguments to your event.
featured image - Learn How to Pass Arguments to Events in Svelte in Just 4 Steps
Johnny Simpson HackerNoon profile picture
Johnny Simpson

Johnny Simpson

@smpnjn

Product, Engineering, Web

About @smpnjn
LEARN MORE ABOUT @SMPNJN'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

Johnny Simpson HackerNoon profile picture
Johnny Simpson@smpnjn
Product, Engineering, Web

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite
Platypush
Coffee-web