menu

arrow_back mootools - scandals, intrigues, investigation

by
2 votes
Maybe I'm stupid, maybe I'm swollen already by 7 am... But please explain to me someone, why this code:

window.addEvent('domready', function() {
console.log(Number.random(5-20));
alert(Number.random(5,20));
});


В первом случае выдает NaN, а во втором случае выдает число. ПОЧЕМУ??? =(

2 Comments

I steamed 3 hours... I went to sleep. >_<
I'm really swollen. Posted a question, sit blunt to him and understand that in the first case, instead of a comma is a hyphen... =) And don't swear, asshole...

2 Answers

by
 
Best answer
0 votes
console.log(Number.random(5-20));
minus the comma change. Night is for sleeping!;)
by
1 vote
WHAT IS MOOTOOLS?????

4 Comments

Dear... You now gave me a link to something that you yourself have denied...

So, looking at the year mootools:
var extend = function(name, method){
if (method && method.$hidden) return;
var previous = this[name];
if (previous == null || !previous.$protected) this[name] = method;
};

// Number.random

Number.extend('random', function(min, max){
return Math.floor(Math.random() * (max - min + 1) + min);
});


И что же это тогда, если не метод?
Oh, apparently I'm not awake yet and realized that the answer I intended. Everything just falls into place and the answer seems logical... =))
That's what . Look at the code and say more stupid things, or do You think that there is a random Number method?
Because console.log() and alert() by definition the error can not give. Sleepy brain I suggested that if the problem lies not in them, it turns out mootools or my mistake. Scrutinizing long did not give results because, again, drowsy inattention. There is the last option. Is it not logical?