简体   繁体   English

为什么在Chrome中未定义String.toLowerCase但在Firefox中未定义?

[英]Why is String.toLowerCase undefined in Chrome but not Firefox?

In the Chrome console, String.toLowerCase returns undefined. 在Chrome控制台中,String.toLowerCase返回未定义。 However in Firefox, it does not. 但是在Firefox中却没有。

What's the reason for the difference? 差异的原因是什么?

 var body = $("body"); body.append(new String(String.toLowerCase).toString()); body.append("<br>"); body.append(String.prototype.toLowerCase.toString()); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 

String.toLowerCase is one of the Generics that Firefox has allowed for String, Array (and possibly other). String.toLowerCase是Firefox允许用于String,Array(可能还有其他)的泛型之一。 They are not defined in any ECMAScript standard and are considered deprecated by Firefox and will be removed. 它们在任何ECMAScript标准中均未定义,并且Firefox已弃用它们并将其删除。

Extracted from the MDN docs : MDN文档中提取:

String generics are non-standard, deprecated and will get removed near future. 字符串泛型是非标准的,已弃用,不久将被删除。 Note that you can not rely on them cross-browser without using the shim that is provided below. 请注意,如果不使用下面提供的填充程序,就不能依靠它们来跨浏览器。

See also: 也可以看看:

Is this what you are trying to do? 这是您要做什么? Either of these work fine in chrome for me. 这些对我来说都适合使用chrome。

 let body = $("body"); let str = 'STRING TO LOWER'; body.append(str.toLowerCase()); body.append("<br>"); body.append("ALL CAPS".toLowerCase()); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 带String.toLowerCase的打字稿字符串比较奇数 - Typescript String Comparison Oddity with String.toLowerCase Expo/React Native 错误 - TypeError: undefined is not an object (evaluating &#39;string.toLowerCase&#39;) - Expo/React Native error - TypeError: undefined is not an object (evaluating 'string.toLowerCase') 为什么Javascript map函数String.toLowerCase在nodejs 6中不起作用? - Why doesn't Javascript map function String.toLowerCase doesn't work in nodejs 6? Chrome与Firefox中的ToLowerCase - ToLowerCase in Chrome vs Firefox 在case转换中,Javascript string.toLowerCase()是否遵循Unicode标准? - Does Javascript string.toLowerCase() follow Unicode standards in case-conversions? String.toLowerCase() 实际上是如何工作的? 如何手动创建该功能? - How does String.toLowerCase() actually work? How can one create that functionality manually? 为什么 Chrome 和 FireFox 控制台打印“未定义”? - Why does Chrome & FireFox console print 'undefined'? Firefox和Chrome中的getElementsByTagName&#39;undefined&#39;吗? - getElementsByTagName 'undefined' in Firefox and Chrome? 为什么 Firefox 和 Chrome 控制台中像“}{”这样的结构会返回“未定义”? - Why does a construction like '}{' in the Firefox and Chrome console return 'undefined'? axios promise值在Chrome控制台中返回undefined,在Firefox控制台中返回字符串 - axios promise value returns undefined in Chrome console and a string in Firefox console
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM