Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

toggle function in javascript

let flag = false;

const toggle = () => {
	if ( flag ) {
     // insert code here when flag is on/true
    } else {
    // insert code here when flag is off/false
    }
    flag = ! flag;
}
Source by www.delftstack.com #
 
PREVIOUS NEXT
Tagged: #toggle #function #javascript
ADD COMMENT
Topic
Name
2+2 =