How do I parse a string to number while destructuring?

前端 未结 8 1055
[愿得一人]
[愿得一人] 2020-12-05 10:23

I am trying to experiment around destructuring assignment. Now I have a case which I trying to cop up with destructuring itself.

For example, I have an input like th

8条回答
  •  抹茶落季
    2020-12-05 11:04

    If you don't mind using lodash, you can try this:

    import { mapValues } from 'lodash';
    
    const input = {latitude: "17.0009", longitude: "82.2108"}
    const {latitude, longitude} = mapValues(input, Number);
    

提交回复
热议问题