Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript toggle value

let bool = true
// with function
function toggle () {
  // long way
  if(bool){
    bool = false
  } else {
    bool = true
  }
  // short way
  bool = !bool
}

// inline way 1
bool = bool ? false : true
// inline way 2
bool = !bool
 
PREVIOUS NEXT
Tagged: #javascript #toggle
ADD COMMENT
Topic
Name
4+1 =