How to implement a function that returns 0 or 1 each time it is executed

how to implement a function that returns 0 or 1

each time it is executed

beginner js, wants to implement a toggel function similar to jQuery

related codes

// :
fn(){}
fn() //0  1
//fn()
Dec.03,2021

var fn = (function(){
    var bool = true;
    return function(){
        bool = !bool;
        console.log(bool ? 1 : 0);
    }
})()
fn()
fn()

// flag=truefalse 
function toggle(flag){
    return !flag
}

the first reaction is also closure

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e48e4f-44ce7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e48e4f-44ce7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?