Is there a significant difference between the following two implementations of the function sorted_copy(NOTE: only their last lines differ):
function sorted_copy ( array ) {
var extra_args = Array.prototype.slice.call( arguments, 1 );
var copy = array.slice();
return Array.prototype.sort.apply( copy, extra_args );
}
function sorted_copy ( array ) {
var extra_args = Array.prototype.slice.call( arguments, 1 );
var copy = array.slice();
return copy.sort.apply( copy, extra_args );
}
More generally, assuming that we have a variable someInstanceat hand 1 whose value is indeed an instance of SomeType 2 and that argsis some suitable instance Array, when there is reason to prefer one of the other to the following:
SomeType.prototype.someMethod.apply( someInstance, args );
someInstance.someMethod.apply( someInstance, args );
Similarly, if arg1, arg2... - some sequence of values when there is reason to prefer one or the other of the following?
SomeType.prototype.someMethod.bind( someInstance, arg1, arg2, ... );
someInstance.someMethod.bind( someInstance, arg1, arg2, ... );
1 , , , SomeType.prototype.someMethod... , , someMethod. , 1 sorted_copy copy (.. ) Array.prototype.sort.apply( array.slice(), extra_args ). , someInstance , , SomeType.prototype.someMethod... .
2 , , someInstance.someMethod - , , SomeType, - .