Sul mio libro leggo:
ma mi sono chiesto per quale ragione non scrivere questo:codice:function myModule(amd1, amd2) { var testResults = { test1: amd1.test(), test2: amd2.test() }, api = { testResults: function () { return testResults; } }; return api; }
i due codici non sarebbero identici? La mia soluzione non sarebbe migliore? Perché l'autore usa la prima?codice:function myModule(amd1, amd2) { var testResults = function testResults() { return { test1: amd1.test(), test2: amd2.test() }; }; return testResults(); }
P.S.: Questa soluzione non sarebbe ancora più semplice?
codice:(function testResults() { return { test1: amd1.test(), test2: amd2.test() }; }());


Rispondi quotando