0

Based on the chaining rules for JavaScript, I have been using the following shortcut syntax to clear closure variables:

//Clear closure variables....
a=b=c=d=e=f=null;

For context, the situation might be:

// variables a,b,c,d,e are defined somewhere up here.

doSomething(function callback() {
   // Do a bunch of work with a,b,c,d,e
   // Now clear variables
   a=b=c=d=e=null;
});

Is this a reasonable way to set a bunch of variables to null concisely?

Community
  • 1
  • 1
tohster
  • 6,973
  • 5
  • 38
  • 55

1 Answers1

1

Yes, it totally is.

Altough I prefer spaces around assignment operators.

And you hardly ever really need to null out closure variables. If you work on such advanced stuff, chained assignments are a minor concern.

Bergi
  • 630,263
  • 148
  • 957
  • 1,375