闭包

let counter = (()=>{
    let number=0;
    return {
    get:()=>number,
    set:val=>isNaN(val)?console.error("Not a number"):number=val,
    plus:()=>++number,
    minus:()=>--number,
    reset:()=>number=0
    }
  })()
«Newer      Older»

----Comments(1)----
@ywap | @ at 2020-07-31 01:12:
let counter = (()=>{
let number=0;
return {
get:()=>number,
set:val=>isNaN(val)?console.error("Not a number")
:number=val,
plus:()=>++number,
minus:()=>--number,
reset:()=>number=0
}
})()
Comment:
Name:


Subscribe | Register | Login | N