Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

? operator in js

? call ternary operator is shorcut for, "if statement".
// below we make object with key id, and assign it a value from body.id.
// if body.id is null it will return false and it will assign it res.id value.
{ id: body.id? body.id : res.id }
// we can write it in if statement like this
if(body.id){
 return {id:body.id}
}else{
  return {id:res.id}
}
 
PREVIOUS NEXT
Tagged: #operator #js
ADD COMMENT
Topic
Name
9+3 =