标签:
function rgb(r, g, b){ var tstring = function(v){return v <= 0? ‘00‘ : v >= 255 ? ‘ff‘ : v.toString(16);}; var result = tstring(r) + tstring(g) + tstring(b); return result.toUpperCase(); } console.log(rgb(456,45,-7));//rgb 转换hex
var numberToPrice = function(number) { var result,num; if(isNaN(number)||number == 0){ return ‘NaN‘; } else{ num = String(number).replace(/(\d+\.\d{0,2})\d*/,‘$1‘); num = Number(num).toFixed(2); result = num.split(‘‘).reverse().join(‘‘).replace(/(\d{3}(?=\d))/g, ‘$1,‘).split(‘‘).reverse().join(‘‘);// 这句是核心,copy的。位运算能实现么? return result; } };
标签:
原文地址:http://www.cnblogs.com/010-88888888/p/4515684.html