3 ms·
isnt this just named parameters?
by hyuuu 5y ago
isnt this just named parameters?
- mkl 5y agoIt's an approximation to named parameters, yes. JavaScript doesn't support them.
- benatkin 5y agoThe closest thing to named parameters in TypeScript is using objects with readonly properties and const assertions where appropriate. It makes it so the objects are basically just fixed key/value pairs. They're used in Deno. https://blog.logrocket.com/const-assertions-are-the-killer-new-typescript-feature-b73451f35802/ https://blog.logrocket.com/const-assertions-are-the-killer-n... It isn't just about protecting the caller of a function from having to deal with the function unexpectedly modifying the object. It's also about an async function not having to make a copy of it to prevent the app calling it from changing it before it's returned.
- Spivak 5y agoYep, this is something I think Python got very right that parameter names are part of the user-facing API of every callable. https://gist.github.com/lucasnad27/e93b8f316259be3299e5#clarify-function-calls-with-keyword-arguments https://gist.github.com/lucasnad27/e93b8f316259be3299e5#clar...