Whoa! That is invalid ECMAScript that relies on browser-dependent syntax
extensions.
Why do that, when you can easily write the same code with valid syntax?
var slice = (function($slice){
try {
$slice.call(document.childNodes);
var slice = function(list){
return $slice.call(list);
};
} catch(e) {
slice = function(){
for(var r = [], i = 0, length = list.length; i < length; ++i)
r[i] = list[i]
;
return r;
};
};
return slice;
})(Array.prototype.slice);
Or:
var slice = (function($slice){
try {
$slice.call(document.childNodes);
return function(list){
return $slice.call(list);
};
} catch(e) {}
return function(){
for(var r = [], i = 0, length = list.length; i < length; ++i)
r[i] = list[i]
;
return r;
};
})(Array.prototype.slice);
-Mike
On Mon, Sep 14, 2009 at 3:11 PM, Andrea Giammarchi <
[email protected]> wrote:
> Kean I do not get with who you are talking, is it me? I perfectly know
> kangx post, I knew before (old codes in devpro) , and I use a strategy not
> even mentioned in kangax post where the last fallback is always the IE one
> to avoid redundancy and any kind of problem ... e.g.
>
> var slice = (function($slice){
> try {
> $slice.call(document.childNodes);
> function slice(list){
> return $slice.call(list);
> };
> } catch(e) {
> function slice(){
> for(var r = [], i = 0, length = list.length; i < length; ++i)
> r[i] = list[i]
> ;
> return r;
> };
> };
> return slice;
> })(Array.prototype.slice);
>
>
> I said about functions just because it is not only about var, being this is
> the oddity post ... got it? :-)
>
> Regards
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---