-
Notifications
You must be signed in to change notification settings - Fork 85
can i parse string to number while destructuring ? #66
Comments
Hello, you solved it? |
This is a stage 4 proposal which means nothing can be added. I think this requirement could be move to pattern match proposal and see what we can do. |
Yes but not the way i wanted, it would have been great if i could have done during destructuring itself but with current implementation it seems not possible. Here are some answer on the same question i asked on https://stackoverflow.com/questions/55194118/how-do-i-parse-a-string-to-number-while-destructuring , specially this answer https://stackoverflow.com/a/55197490/9624435 |
@hax Thanks mate, very new to all this, i just found out that this can be handy in many circumstances so thought of asking here, Didn't knew about pattern-matching thing before, i'll go through proposal for sure, let me know if there's anything i can contribute as well as a newbie 😁 |
I think that's good. You can define your criteria in the numberinput function to convert to Number. 🚀 |
This is just a question.
For example, I have an input like this:
let input = {latitude: "17.0009", longitude: "82.2108"}
Where
latitude
andlongitude
key's value are strings, but I want to parse them into a number while destructuring.I can see in babel repl that this takes a reference of an object and then access each key. So the above code is the same as:
I want do something like using the destructuring syntax itself.
The text was updated successfully, but these errors were encountered: