-1

I have an 'init' function in which i have few variables which i want to set as undefined/null on logout event.

var EmpCode;
function initChat(user, usertoken, ip){ 
  if(user!= null){
    EmpCode = user;
    var time_id = Date.now();
//some function calls.
}

function logout(){
//reset variable
}

i want to reset 'EmpCode' variable value on on logout function.

delete EmpCode; does not seems to work because it is defined by keyword var.

  • 1
    `delete` just works on properties, what do you mean with reset? you can set it like this `EmpCode = undefined`. If you declare it like this `var EmpCode;` its automatically undefined at this point – bill.gates Jun 02 '20 at 08:11

1 Answers1

2
function logout(){
  //reset variable
  EmpCode = undefined; // or null
}
sl2782087
  • 136
  • 5