我必须在下面的方法中使用bind().我只想支持IE10及以上版本.任何人都可以验证IE10何时或是否支持bind()?
// Verify console exists
...
if (window.console) {
logger = window.console.log.bind(window.console);
// bind needed for Safari but not FF, possible IE issue?
} else {
return false; // window.console not available, silent fail
}
...
Run Code Online (Sandbox Code Playgroud) 以下脚本在IE 9,IE 10,IE 11中不起作用
var a = location;
var b = 'toString'
var c = a[b].bind(a);
c(); // "Invalid calling object in IE"
Run Code Online (Sandbox Code Playgroud)
有没有解决方法呢?
编辑 - 链接问题中提供的MDN垫片不起作用!! 它们适用于IE 8!我对IE> 8的问题,其中Function.bind是"支持的".