Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

question mark in javascript

boolean statement ? true result : false result;

/*
For example, if we take this if statement:
*/
if (a > b) {
    result = x;
} else {
    result = y;
}
// can be also writen:
result = a > b ? x : y;
Comment

javascript question mark

//This is what is called a 'Conditional operator'
let result = condition ? value1 : value2
//               ^^        ^^      ^^
let result =  1 == 2   ?  "YES" : "NO!"
console.log(result)  //output: "NO!"

//Basically a short form of an if-else statment
Comment

question mark in javascript

(condition) ? {code for YES} : {code for NO}
Comment

PREVIOUS NEXT
Code Example
Javascript :: start live server react js 
Javascript :: object assign 
Javascript :: react-data-table-component edit action 
Javascript :: trim text and add ... js 
Javascript :: mongoose rename collection 
Javascript :: push javascript 
Javascript :: axios interceptors 
Javascript :: loop react components 
Javascript :: get all files in directory recursively nodejs 
Javascript :: react chartjs 
Javascript :: export table data to excel using javascript or jquery 
Javascript :: sum of an array 
Javascript :: object promise javascript 
Javascript :: add class to html tag javascript 
Javascript :: find object from list 
Javascript :: javascript loop counter 
Javascript :: navigate json object javascript 
Javascript :: Creating with the custom hook in react 
Javascript :: js number round to each 15 
Javascript :: loop do while javascript 
Javascript :: react.lazy 
Javascript :: afficher une variable dans la console javascript 
Javascript :: Toasting a message 
Javascript :: what is getter and setter in javascript 
Javascript :: como percorrer um objeto js 
Javascript :: date object js 
Javascript :: jquery select element with class 
Javascript :: how to convert react component to image 
Javascript :: nodejs send download file from buffer 
Javascript :: take string until react 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =