Js-各種基本タイプ間の変換

6071 ワード

  • デジタル変換文字列
  • let num = 24
    let str1 = num.toString() 
    let str2 = num + ''
    
  • 文字列回転数
  • let s = '24'
    let num1 = Number(s) 
    let num2 = s - 0
    let num3 = parseInt(s)
    
  • デジタル変換行列
  • let num = 24
    let numArr = num.toString().split('').map(Number)
    
  • デジタル変換文字列配列
  • let num = 24
    let strignArr = num.toString().split('')
    
  • 数字配列または文字列配列回転数
  • let numArr1 = [1,8,24]
    let numArr2 = ['1','8','24']
    let num1 = numArr1.join('') - 0 
    let num2 = Number(numArr2.join(''))
    let num3 = parseInt(numArr1.join(''))
    
  • 数字配列変換文字列配列
  • let numArr = [1,8,24]
    let strArr = numArr.map(String)
    
    
  • 文字列変換配列
  • let str='Franklin'
    let arr1 = str.split('')
    let arr2 = Array.from(str)