为什么Math.log10在某些系统上工作但在其他系统上返回undefined? [英] Why does Math.log10 work on some systems but return undefined on others?

查看:77
本文介绍了为什么Math.log10在某些系统上工作但在其他系统上返回undefined?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个基于html5画布的应用程序,用于绘制电位作为颜色图。我使用Math.log10来重新调整值,这在很多系统上运行良好(Chrome-Firefox-Opera;笔记本电脑和PC; Windows和Ubuntu;集成和专用图形)。然后我发现一台PC和一台笔记本电脑都带有Windows,其中的情节不起作用。错误显示Math.log10()无法作为函数调用,只是在js控制台中键入Math.log10返回undefined。我通过用Math.log(someValue)/2.3替换Math.log10(someValue)来解决这个问题。
所以我的问题是:为什么会发生这种情况并且还有其他类似令人烦恼的差异?

I wrote an html5 canvas based app for plotting the electric potential as a color-map. I was using Math.log10 to re-scale the values and this worked well on quite a few systems (Chrome-Firefox-Opera; laptops and PC; Windows and Ubuntu; integrated and dedicate graphics). And then I found one PC and one laptop both with Windows where the plot would not work. The error was showing that Math.log10() could not be called as a function and just typing Math.log10 in the js console returned undefined. I got around this glitch by replacing Math.log10(someValue) with Math.log(someValue)/2.3. So my questions are: why does this happens and are there any other similar annoying differences?

推荐答案

这是浏览器-具体。并非所有浏览器都支持实验性的 Math.log10()函数 - 主要是Internet Explorer。

This is browser-specific. Not all browsers support the experimental Math.log10() function - the main one being Internet Explorer.

Math.log()但是是一个单独的函数,它早在 Math.log10()之前就已经引入了,并且有更多的浏览器支持。

Math.log() however is a separate function which was introduced long before Math.log10(), and has much greater browser support.

Mozilla开发者网络列出浏览器支持 Math.log10()

The Mozilla Developer Network lists browser support for Math.log10():


桌面浏览器



Desktop Browsers

Chrome    Firefox (Gecko) Internet Explorer   Opera   Safari
38        25 (25)         Not supported       25      7.1



移动浏览器



Mobile Browsers

Android         Chrome for Android    Firefox Mobile (Gecko)  IE Mobile      Opera Mobile    Safari Mobile
Not supported   Not supported         25.0 (25)               Not supported  Not supported   iOS 8


这篇关于为什么Math.log10在某些系统上工作但在其他系统上返回undefined?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆