“tanda seru ganda JS” Kode Jawaban

tanda seru ganda JS

// "!!" converts a value to a boolean, then inverts it and then inverts it again.
// So let's say you want to check the value for a given variable:
const num = null; 

if (num) { // false -> value is null -> evaluated as falsy
}
if (!num) { // true
}
if (!!num) { // false
}
// another example
const str = "Hello World";

if (str) { // true -> value is a "proper" (not empty) string -> evaluated as truthy
}
if (!str) { // false
}
if (!!str) { // true
}
Pl0erre

tanda tanya ganda javascript

let a = null;
const b = a ?? -1;		// Same as b = ( a != null ? a : -1 );
console.log(b);		  	// output: -1
//OR IF
let a = 9;
const b = a ?? -1;
console.log(b);  		// output: 9

//PS.,VERY CLOSE TO '||' OPERATION IN FUNCTION, BY NOT THE SAME
Lazurite

Jawaban yang mirip dengan “tanda seru ganda JS”

Pertanyaan yang mirip dengan “tanda seru ganda JS”

Lebih banyak jawaban terkait untuk “tanda seru ganda JS” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya