How’s it going, I'm a Adam, a Full-Stack Engineer, actively searching for work. I'm all about JavaScript. And Frontend but don't let that fool you - I've also got some serious Backend skills.
Location
City of Bath, UK 🇬🇧
Education
10 plus years* active enterprise development experience and a Fine art degree 🎨
Great question, yes decorators are implicitly connected to the next valid block of code they can find (JavaScript doesn't care about whitespace), that's why you can place a decorator above a method or inline.
@myDecsomeMethod(){}
Or
@myDec(someInterceptingParam)someMethod(){}
Or
@myDecsomeMethod(){}
Or in my case
@get["/home"]// <- that's a method name(){}
I could have done (probably should have done)
@get('/home')handleHomePage(){}
But you can see that this allows a URL to be used by two methods as the URL is now not tied to the method name and also there is more to type.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
How is the code below a decorator connected to the decorator above it? Implicitly?
Great question, yes decorators are implicitly connected to the next valid block of code they can find (JavaScript doesn't care about whitespace), that's why you can place a decorator above a method or inline.
Or
Or
Or in my case
I could have done (probably should have done)
But you can see that this allows a URL to be used by two methods as the URL is now not tied to the method name and also there is more to type.