@Sathyasatz
Full Stack Developer
Nothing here yet.
Nothing here yet.
No blogs yet.
In simple words, Singleton means Assume u having an object but it is injected in many places, but it only uses object reference, In AngularJS all services are singletons. service, providers, factory, constants all are a singleton. Eg: If you wanna access a data from one controller to another controller singleton service is used. Refer this for clear idea on service & factory.
To be short, V8 uses a heap similar to JVM, local variables are put on the stack and objects in the heap. Consider this code, function foo(b) { var a = 10; return a + b + 11; } function bar(x) { var y = 3; return foo(x * y); } console.log(bar(7)); When we call bar() it will create a frame in stack with name bar and with respective arguments and when it ends it gets to pop out from stack, There really was no recursion in my code, if it has "Maximum call stack size exceeded" exception will be thrown, so stack frame is used in this way of memory allocation. I think most of the global variables use heap and it appears when memory leaks occur