pourquoi est-ce pas ok?Pourquoi dit-on que xxx n'est pas une fonction
aContract = function(){};
aContract.prototype = {
someFunction: function() {
alert('yo');
},
someOtherFunction: some$Other$Function
};
var some$Other$Function = function() {
alert('Yo yo yo');
};
var c = new aContract();
c.someFunction();
c.someOtherFunction();
Firebug dit c.someOtherFunction est pas une fonction
Mais cela fonctionne très bien
aContract = function(){};
aContract.prototype = {
someFunction: function() {
alert('yo');
},
someOtherFunction: some$Other$Function
};
function some$Other$Function() {
alert('Yo yo yo');
};
var c = new aContract();
c.someFunction();
c.someOtherFunction();
Qu'est-ce que je manque ici ??? Je préfère coder en javascript en utilisant la première méthode, qui fonctionne généralement bien, mais ne semble pas fonctionner correctement lorsque je prototype.
Merci, ~ ck Sandy Eggo
Ce n'est pas vrai du tout. Appeler blah() affiche "undefined": fonction blah() { alert (x); var x = 5; } –
Ce n'est pas tout à fait ce qui se passe. par exemple. (function() {var a = x + 1; var x = 2; renvoie a;}))() retourne NaN. Vous pourriez penser plus à (fonction() {var a = fonction() {return x + 1}; var x = 2; retourner un()})() qui renvoie 3. – BaroqueBobcat