skip to Main Content

i try to do one exercise ,this var have to be undefined

var var1 = 'hello world'

if someone can help me ?

my var have to be undefined but , i cant change anything to my var from var to ‘hello world’ its an exercise for my school

2

Answers


  1. You can undefine the variable:

    var var1 = 'hello world';
    var1 = undefined;
    console.log(var1);
    
    Login or Signup to reply.
  2. var var1 = ‘hello world’;
    delete var1;

    You can achieve this by using ‘delete’. please be cautious when using the delete operator in real cod.

    If this is NOT your answer please do let me know.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search