-2

Let's take some javascript code from vk.com

var stManager = {

   //some long code with methods and properties...

}, __stm = stManager;

Why do we need last line in this code? Why duplicate stManager one more time?

Vijay
  • 2,965
  • 1
  • 15
  • 24
Aleksander A
  • 311
  • 2
  • 10
  • 1
    You're just declaring and initializing another variable (_stm) with the same value as stManager (hence making a copy of it) ... you may need the original value to make future value comparisons while keeping the original. – henser Jan 29 '15 at 09:40
  • 2
    You edited the question and now it changed the entire context.....you might need a copy of `stManager`...hence you are using it. – Vijay Jan 29 '15 at 09:41
  • Good job completely changing what this question is about. – Cerbrus Jan 29 '15 at 09:44
  • Thank you for answers. Main thing is to make everything clear. Even if it seems to be stupid :) – Aleksander A Jan 29 '15 at 09:50

2 Answers2

1

You are declaring and initializing multiple variables with single 'var' thats it...

var x=1,y=2;
Vijay
  • 2,965
  • 1
  • 15
  • 24
0

It means you are declaring another variable. Just a different notation. It is the same as:

var stManager = {};
var _stm = stManager;
David
  • 104
  • 6