本文总结的代码片断(六)--持续更新前端
前端经常使用代码片断(一) 点这里
前端经常使用代码片断(二) 点这里
前端经常使用代码片断(三) 点这里
前端经常使用代码片断(四) 点这里
前端经常使用代码片断(五) 点这里
前端经常使用代码片断(六) 点这里segmentfault
console.log( 'Nothing here %cHi Cat %cHey Bear', // Console Message 'color: blue', 'color: red' // CSS Style );
const styles = ['color: green', 'background: yellow'].join(';'); const message = 'Some Important Message Here'; // 3. 传入styles和message变量 console.log('%c%s', styles, message);
本节参考文章:多彩的console.logpost
function version( v1, v2 ) { var arr1 = v1.replace(/[-_]/g,'.').split('.'); var arr2 = v2.replace(/[-_]/g,'.').split('.'); console.log(arr1,arr2); var len = Math.max(arr1.length, arr2.length); for ( var i = 0; i < len; i++ ) { if(parseInt(arr1[i]) == parseInt(arr2[i])) continue; return parseInt(arr1[i]) < parseInt(arr2[i]) ? true :false; } return false; }
本节参考文章:如何比较版本号大小spa