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最后演变成了看着大神在那边互相比拼实力.. 小森执行一 ...
随机推荐
- TPS61040/61041 开关电源稳压器(DC-DC) ADJUST
Variable Control Voltage Output Voltage Adjust This method is accomplished by connecting a variable ...
- Wix使用整理(二)
1) 安装卸载时进行日志记录 Wix 制作的 Installer 的调试很麻烦,没有直接的 Bug 工具,可以通过记录安装日志的方式进行间接调试.命令为 msiexec /i pack ...
- find命令专辑
find命令使用技巧 查找文件,移动到某个目录 使用find和xargs 15条 linux Find 命令实际使用方法 find 命令用法 find命令使用经验 find用法小结 find与xarg ...
- 【layer】关于layer打开就是最大化的使用
使用layer时候 想在弹出层 在打开的时候默认就是最大值 perContent = layer.open({ type:2, title: userName+nowDate+"的" ...
- asp.net Core 中间件Hello world
虽然在ASP.NET 5中,微软没有再强调OWIN(Open Web Interface for .NET)及其微软官方的OWIN实现Katana,但是其中涉及到一些原则和设计思想依然被ASP.NET ...
- C99规范
. 增加restrict指针 C99中增加了公适用于指针的restrict类型修饰符,它是初始访问指针所指对象的惟一途径,因此只有借助restrict指针表达式才能访问对象.restrict指针指针主 ...
- 通过nc构造telnet后门
nc被称为网络中的“瑞士军刀”,其功能强大,如果在肉鸡上运行“nc.exe –p port –L –d –e cmd.exe”命令就可以构建一个telnet后门,即使关闭了nc.exe程序运行窗口,该 ...
- go语言基础之输入的使用
1.输入的使用 第一种写法:fmt.Scanf("%d", &a) 第二种写法:fmt.Scan(&a) 示例: package main //必须有一个main包 ...
- 设置 IE 默认模式为 IE8
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
- Python 高级图像处理
构建图像搜索引擎并不是一件容易的任务.这里有几个概念.工具.想法和技术需要实现.主要的图像处理概念之一是逆图像查询(RIQ).Google.Cloudera.Sumo Logic 和 Birst 等公 ...