console.log 颜色怎么输出特殊字符编写的图案

五一节太闲了,竟研究起这个来&
Sublime Text
ASCII Generator
用ASCII Generator生成字符画,复制到js文件,直接<出来。
当然不可能这么顺利的,会报错
Uncaught SyntaxError: Unexpected token ILLEGAL
原因是字符画中包含有&回车换行符&,整日敲代码的你肯定知道,把不能识别的回车换成\n就行了。
这么多行一个个加\n未免太慢了,那就该神器Sublime该出场了。
想必你已经知道,在sublime中用中键(就是滚轮啦)可以选择多行:
选择多行同时加上了\n,再按home键把光标移到行首,删除&回车换行&!
大工告成,字符画已经变成一行代码了!
这时候把它<出来看看吧!
本文发表于:&&转载请注明出处
阅读(...) 评论()14:19 提问
console.log(8 | 1),为什么会输出9?为什么不是8而是9呢?我搞不懂
console.log(8 | 1),为什么会输出9?为什么不是8而是9呢?我搞不懂
按赞数排序
8的二进制表示是的二进制表示是,操作符|表示按位或,所示结果是,对应十进制9
知道什么是或运算吗?
用错运算符了吧,要8应该是||,而不是|
console.log(8 ||1)
位或运算,实际和加法一样。z z
1000 + 0001
等于多少啊
?大致是这个意思吧使用 console.log 在浏览器开发者工具控制台中输出带样式的调试文本
编辑:Shane Jhu阅读 ()
在百度首页启动浏览器开发者工具时,发现网页中使用 console.log() 输出了一段招聘信息,不得不说这种发布方式很有创意而且更有针对性。该代码中使用了颜色样式,但这种样式在 IE 和 Edge 中是无效的,会将所有参数当做普通字符一并输出。本文就介绍 console.log() 输出带颜色格式的写法,附带判断浏览器类型。/*检测浏览器类型*/
function&uaMatch()&{
&&&&var&userAgent&=&navigator.userAgent,
&&&&&&&&&&&&rEdge&=&/(edge)\/([\w.]+)/,
&&&&&&&&&&&&rMsie&=&/(msie\s|trident.*rv:)([\w.]+)/,
&&&&&&&&&&&&rFirefox&=&/(firefox)\/([\w.]+)/,
&&&&&&&&&&&&rOpera&=&/(opera).+version\/([\w.]+)/,
&&&&&&&&&&&&rChrome&=&/(chrome)\/([\w.]+)/,
&&&&&&&&&&&&rSafari&=&/version\/([\w.]+).*(safari)/;
&&&&var&ua&=&userAgent.toLowerCase();
&&&&var&match&=&rEdge.exec(ua);
&&&&if&(match&!=&null)&{
&&&&&&&&return&{&browser:&&EDGE&,&version:&match[2]&||&&0&&};
&&&&var&match&=&rMsie.exec(ua);
&&&&if&(match&!=&null)&{
&&&&&&&&return&{&browser:&&IE&,&version:&match[2]&||&&0&&};
&&&&var&match&=&rFirefox.exec(ua);
&&&&if&(match&!=&null)&{
&&&&&&&&return&{&browser:&match[1]&||&&&,&version:&match[2]&||&&0&&};
&&&&var&match&=&rOpera.exec(ua);
&&&&if&(match&!=&null)&{
&&&&&&&&return&{&browser:&match[1]&||&&&,&version:&match[2]&||&&0&&};
&&&&var&match&=&rChrome.exec(ua);
&&&&if&(match&!=&null)&{
&&&&&&&&return&{&browser:&match[1]&||&&&,&version:&match[2]&||&&0&&};
&&&&var&match&=&rSafari.exec(ua);
&&&&if&(match&!=&null)&{
&&&&&&&&return&{&browser:&match[2]&||&&&,&version:&match[1]&||&&0&&};
&&&&if&(match&!=&null)&{
&&&&&&&&return&{&browser:&&&,&version:&&0&&};
&&&&var&browser&=&uaMatch().
&&&&if(browser.toUpperCase()&==&&IE&&||&browser.toUpperCase()&==&&EDGE&){
&&&&&&window.console&&window.console.log&&(
&&&&&&&&console.log(&【Lena&?&Shane】&),
&&&&&&&&console.log(&逆风的方向\n更适合飞翔&),
&&&&&&&&console.log(&/&)
&&&&}&else&{
&&&&&&window.console&&window.console.log&&(
&&&&&&&&console.log(&%c【Lena&%c?&%cShane】&,&color:black&,&color:pink&,&color:black&),
&&&&&&&&console.log(&%c逆风的方向\n更适合飞翔&,&color:#1d6402&),
&&&&&&&&console.log(&%c/&,&color:red&)
}catch(e){}Chrome中的效果:Microsoft Edge中的效果:本文由原创,转载请注明出处:
上一篇:下一篇:
Copyright (C)
保留所有权利

我要回帖

更多关于 console.log 的文章

 

随机推荐