Mögliche Duplizieren:
What good does zero-fill bit-shifting by 0 do? (a >>> 0)Was macht x >>> 0?
Ich habe in einem Projekt von mir einige funktionale Programmierung Konzepte auszuprobieren und ich las über Array.prototype.map
, die in ES5 ist neu und sieht aus wie dies:
Array.prototype.map = function(fun) {
"use strict";
if (this === void 0 || this === null) {
throw new TypeError();
}
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun !== "function") {
throw new TypeError();
}
var res = new Array(len);
var thisp = arguments[1];
for (var i = 0; i < len; i++) {
if (i in t) {
res[i] = fun.call(thisp, t[i], i, t);
}
}
return res;
};
Was ich frage mich, ist, warum es t.length >>> 0
tun. Weil es nichts zu tun scheint. x >>> 0 //-> x
! (solange x eine Zahl ist, natürlich)
Beachten Sie auch, dass ich nicht weiß, wie bitweise Operatoren arbeiten.
und viele andere http://stackoverflow.com/questions/1822350/ http://stackoverflow.com/questions/1474815/ http://stackoverflow.com/questions/1385491/ http: // stackoverflow.com/questions/3348438/ Diese sind nur dann einfach zu finden, wenn der erste gefunden wurde> _>. – kennytm
@KennyTM ~ Gute Duplikate, wenn Sie wissen, was die Namen der Dinge sind ...;) – jcolebrand