1. String.prototype.camelize BUG
This method is used to return the string to the camel's wording. Use JS to control the style of the element when used frequently
Like what
var ss= "Font-color"
Ss=ss.camelize ()//FontColor
Normally camelize will work very well, but there is a special column, that is floating positioning float
var ss= "float"
Obj.style[ss.camelize ()]= "right"//This will result in an error.
Obviously, the author does not consider the special situation of float, the correct formulation is:
Ie:obj.style.stylefloat= "Right"
Ff:obj.style.cssfloat= "Right"
2. String.prototype.inspect BUG
Here the inspect method is a bug, and the author uses the Replace method without a regular, resulting in only the substitution of the first matching character.
It should be the right way to do it.
Inspect:function () {
Return "'" + this.replace (/\\/g, ' \\\\ '). Replace (/"/g, ' \\\") + "'";
}
3. Array.prototype.all BUG
This method detects whether all elements in an array can make the iterated function true. Returns true if all is satisfied, otherwise returns false
var f=function (x) {return x%2==0}//Check if a number is an even
var arr=[2,4,6]
Alert (Arr.all (f) ==true)//show True
But when arr is empty, it still returns true
var arr=[]
Alert (Arr.all (f) ==true)//show True
4. Array.prototype.any BUG
With the all method, the null array still returns TRUE
5.array.prototype.detect is also the Find method
This is not a Bug, but not looking at the original code is easy to misunderstand, and thus error.
This method finds the first element that satisfies the iteration function, and finally returns the value of the element.
Misunderstanding one:
var f=function (x) {return x%2==0}//detect if an even
var arr=[1,3,5,7]//intentionally defines an array that is all odd.
Alert (Arr.find (f) ==false)//false
Many people mistakenly assume that the Find function returns False when the element that satisfies the condition is not found, in fact, it returns "undefined"
Misunderstanding two:
Finding the numeric elements in an array
var f=function (x) {return!isnan (x) && typeof (x) = = "Number"}
var arr=[false, "Go_rush", 0, "Asun"]
if (Arr.find (f)) alert ("contains numeric elements in an array")//In fact, this alert will never be executed.
Because the Find method returns the first qualifying value. Here returns: 0. So.....
6. The processing of the hash object needs to be extra careful where
var hash={member:1,test:2,ids:3}
Alert (Hash.member)
Alert ($H (hash). Inspect ())
Alert ($H (hash). Toquerystring ())
Hash.member actually exists, but. Inspect () and. Toquerystring () But when it does not exist
The following properties also conflict with Prototype.js.
Each, all, any, collect, detect, FindAll, grep, include, inject, Invoke, Max, Min,
Partition, Pluck, Reject, sortby, ToArray, zip, inspect, map, find, select, member, entries
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.