Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
{} + {}Math.min() < Math.max();
// falseif (cond)
code1();
code2();
for(var i=0;i<10;++i);
sum+=i;for(var i=0;i<10;++i); // тут стоит точка с запятой - тело цикла нет
sum+=i; // будет ReferenceError или +10 если sum объявлен как числоvar i=5;i=++i + ++i; // i?function Dude(name){
this.name = name;
return [1, 2, 3];
}
new Dude('Bob');
// [1, 2, 3]
function Dude(name){
this.name = name;
return 3;
}
new Dude('Bob');
// { name: 'Bob' }
The object returned by the constructor function becomes the result of the whole new expression. If the constructor function doesn't explicitly return an object, the object created in step 1 is used instead. (Normally constructors don't return a value, but they can choose to do so if they want to override the normal object creation process.)
function Dude(name){
this.name = name;
return new Number(3);
}
new Dude('Bob'); // Number(3)var minNextValue = Math.max.apply( max, fetchValuesFromDb() );
Math.random она вернёт число от -Infinity до Infinity? От 0 до 1? В каждом языке — по разному.var max = -Infinity,
values = [];
for (var i = values.length; i --> 0;) {
if (values[i] > max) {
max = values[i];
}
}
return max; // если values.length === 0 то вернется -Infinity
Math.max( ) => values = []
Math.max(1 ) => values = [1]
Math.max(1,2) => values = [1,2]Math.min(NaN,2,3);
// NaN
Math.max(NaN,2,3);
// NaN
min ( [ value1 [, value2 [, … ] ] ] )
Given zero or more arguments, calls ToNumber on each of the arguments and returns the smallest of the resulting values.
* If no arguments are given, the result is +Infinity.
* If any value is NaN, the result is NaN.
* The comparison of values to determine the smallest value is done as in 11.8.5 except that +0 is considered to be larger than -0.
The length property of the min method is 2.
Wat