JavaScript字符串类型和数值类型的转换

JavaScript字符串类型和数值类型的转换

var m_str = "1.0"
var m_num = 1
var m_numtostr =  "" + m_num                   //数值转换成字符串
var m_numtostr = new String(m_num)             //数值转换成字符串
var m_strtonum = 0 + m_str                     //字符串转换成数值

你可能感兴趣的:(cocos,cocos,creator,JavaScript,游戏开发)