[英]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.