Created
          September 20, 2023 09:14 
        
      - 
      
- 
        Save CarlOlson/45d15dde94b5bf1fe650b529e036477f to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | let input = "{\"id\": 1, \"cell\":{\"id\":\"12345678-etc\"}}"; | |
| let obj = JSON.parse(input) | |
| console.log(obj.cell.id); // 12345678-etc | |
| let match = obj.cell.id.match(/^\d*/); | |
| let id = match[0]; | |
| console.log(id) // 12345678 | |
| console.log(typeof id) // string | |
| id = parseFloat(id); | |
| console.log(id) // 12345678 | |
| console.log(typeof id) // number | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment