Can someone explain this Javascript code?
I saw this posted on stackoverflow. How would someone call such a function. The poster did not provide any example, of course.
- Array.max = function( array ){
return Math.max.apply( Math, array );
};
- Here is something I tried. A bad guess:
var array1 = [1,16,0,32,11];
Array.max = function( array ){
return Math.max.apply( Math, array );
};
alert(array1.max);
(I don't know the proper way of providing two code blocks on this forum, so this does look a bit messy)