+ 1

(1)What's the meaning of the condition(bool?) in console?...... (2)pls explain the commented line?

let arr=[5,NaN,6]; let bool=arr.includes(NaN);/*.....explanation pls.....*/ console.log(bool? true :false);

9th Jan 2023, 11:54 AM
Mohammad Tausiful Alam
Mohammad Tausiful Alam - avatar
2 ответов
+ 2
let arr=[5,NaN,6]; let bool=arr.includes(NaN); //this means checking that the array arr is includes or having value NaN ? Yes so it returns true..... (condition)?(exp1) : exp2 //=> is a ternary operator , if condition is true then exp1 is evalueted else the exp2 is evaluated. it is alternative , short way of //if(condition) exp1 else exp2 console.log(bool? true :false);
9th Jan 2023, 12:11 PM
Jayakrishna 🇮🇳
11th Jan 2023, 12:14 PM
Mohammad Tausiful Alam
Mohammad Tausiful Alam - avatar