一、js 字符转换
//.toString() 字符串
// parseInt(X1) 整型
// parseFloat 浮点型
// X1.indexOf 搜索字符
let arr1=[1,2,3,4,5]; let arr2=arr1; let arr3=arr1.map(function(item){ return item; }) console.log(arr1===arr2); console.log(arr1===arr3);
二、字符串与16进制互转
funStrToHex(str){ //字符串转16进制 var val = ""; for(var i = 0; i < str.length; i++){ if (val == "") val = str.charCodeAt(i).toString(16); else val += "," + str.charCodeAt(i).toString(16); } return val; }, funHexToStr(str){ //16进制串转字符 var val=""; var arr = str.split(","); for(var i = 0; i < arr.length; i++){ val += String.fromCharCode(parseInt(arr[i],16)); } return val; },
1,390 Views