TypeError: can't convert console.log(...) to primitive type
一、背景
火狐浏览器提示这个错误,谷歌没有。
二、出错代码
var eventHandlers = {
'succeeded': function(e){
console.log('send success' + e.cause)
},
'failed': function(e){
console.log('send failed,reason='+e.cause)
}
};
三、原因
火狐处理console.log('send success' + e.cause)的时候,会默认把e.cause转换成String类型,所以提示如题的错误。
四、解决办法
不适用字符串拼接的方式,直接打印。
五、修订后的代码
var eventHandlers = {
'succeeded': function(e){
console.log(e.cause),
console.log('send success')
},
'failed': function(e){
console.log('send failed,reason'),
console.log(e.cause)
}
};
六、测试结果
错误消除。
TypeError: can't convert console.log(...) to primitive type的更多相关文章
- console.log的另一种用法
// console.log用法 var foo, bar; console.log(`foo's type: ${foo}`, `bar's type: ${bar}`); 输出:
- JS里try...catch...finally详解,以及console日志调试(console.log、console.info等)
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- js console.log all in one
js console.log all in one this & arguments "use strict"; /** * * @author xgqfrms * @li ...
- const let,console.log('a',a)跟console.log('a'+a)的区别
const 创建一个只读的常量 let块级作用域 const let重复赋值都会报错 console.log('a',a) a console.log('a'+a) a2 逗号的值会有空格:用加号的值 ...
- console.log("A"-"B"+"3")=?
(点击上方的订阅号,可快速关注,关注有惊喜哦^_^) 前不久看到一道JS基础题目,做了一下竟然错了一半...在此分享一下: 先把题目放上来,大家可以自己测试一下再看答案哦^_^ ①console.lo ...
- javascript的console.log用法
f1.html代码 <iframe id="frame2" name="frame1" src="ww.html"></i ...
- alert()与console.log()的区别
[1]alert() [1.1]有阻塞作用,不点击确定,后续代码无法继续执行 [1.2]alert()只能输出string,如果alert输出的是对象会自动调用toString()方法 e.g. al ...
- console.log((function f(n){return ((n > 1) ? n * f(n-1) : n)})(5))调用解析
console.log((function f(n){) ? n * f(n-) : n)})()); 5被传入到函数,函数内部三元计算,5 > 1成立,运算结果是5*f(4),二次运算,5*4 ...
- JS高级群的日常!写一个从10到0的倒计时,用console.log打印,不可以用 setInterval!本来说好的研究avalonJS最后演变成了看着大神在那边互相比拼实力。。
JS高级群的日常!写一个从10到0的倒计时,用console.log打印,不可以用 setInterval!本来说好的研究avalonJS最后演变成了看着大神在那边互相比拼实力.. 小森执行一 ...
随机推荐
- Bipolar transistor boosts switcher's current by 12 times
The circuit in Figure 1 uses a minimal number of external parts to raise the maximum output current ...
- 玩转windowbuilder pro
windowbuilder,也就是原来的SWT Designer.Google收购了Instantiations,把它的工具也重新免费发布了. 下载地址:http://www.eclipse.org/ ...
- 容器+AOP实现动态部署(四)
上篇咱们介绍了容器和AOP的结合,结合后怎样将对象增强服务并没有过多的说明,这里将详细说明怎样将对象 进行增强 ,达到一个一对多和多对多的增强方式 先从简单的方式说起 /** *JDK代理类,实现动态 ...
- js隐藏表格的一行数据
1.方法 document.getElementById('customerAccount_tr').style.display="";//缴纳人名称显示 document.get ...
- 让Netty入门变得简单
让Netty入门变得简单 https://mp.weixin.qq.com/s/MBnbLmCmFJo0QK9WNwXrXQ 如果先启动nettyClient就不会有nettyServer输出了: p ...
- [ACM] POJ 2524 Ubiquitous Religions (并查集)
Ubiquitous Religions Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 23093 Accepted: ...
- [Angular-Scaled web] 3. Basic State with ui-router
1. Install ui-route, include js file in html and add dependence in js file. bower install angular-ui ...
- [AngularJS] ng-change vs $scope.$watch
<div class="form-group"> <label for="pwd">Password</label> < ...
- flex版本问题总结
转自:http://blog.csdn.net/holly_puck/article/details/6690264 最近公司平台在集成工作流时需要设计一个web版的流程定义设计器,初步定下来用Fle ...
- Java中字符串相等与大小比較
在C++中,两个字符串比較的代码能够为: (string1==string2) 但在java中,这个代码即使在两个字符串全然同样的情况下也会返回false Java中必须使用string1.equal ...