Does JavaScript optimize for a function that is defined within the context of another function?
For example, are the following examples canonically represented (in performance terms) after compilation, or is one approach favored optimally over the other?
function sortMyThings() {
var a = ["b", "e", "a", "c", "d"];
a.sort(function(a, b) {
if (a < b) return -1;
if (a == b) return 0;
if (a > b) return 1;
});
}
function sortFunc(a, b) {
if (a < b) return -1;
if (a == b) return 0;
if (a > b) return 1;
}
function sortMyThings() {
var a = ["b", "e", "a", "c", "d"];
a.sort(sortFunc);
}