I am currently reading a book on Javascript by Pragmatic, and I'm confused about one thing. They have a section on how to make variables global, local, or private.   What is the difference between local and private variables? Is there one? How do...
Is it possible to have private properties in a model? Like the locally declared variables in a (constructor) function, not attached to this, but declared locally and visible only by whatever is defined in the (constructor)function.  Example without B...
I've been playing around and searching a bit, but I can't figure this out. I have a pseudo private function within a JavaScript object that needs to get called via eval (because the name of the function is built dynamically). However, the fun...
There is a good generalized method for defining private and protected properties and methods in Javascript, here on the site. However, the current version of Prototype (1.6.0) doesn't have a built-in way to define them through its Class.create()...
I'm trying to create a singleton that has variables not directly mutable from the outside. This is my current code:  var singleton = new (function () {     var asd = 1;     this.__defineGetter__("Asd", function() {         return asd;...
i have this class:  function ctest() {     this.var1 = "haha";     this.func1 = function() {         alert(this.var1);         func2();         alert(this.var1);     }     var func2 = function() {         this.var1 = "huhu";     } }...
In a backbone view where would you put your private variables and your public.  Right now I have something like this:  myView = Backbone.View.extend({    initialize: function(options){     this.myPublic = "I'm public";   }  });   I tried...
i'm quite a newbie in javascript, and i'm spending some time trying to create namespaced objects in js.  Now, that's what i'm trying to do:  MainObject = function() {      var privateVariable = "i'm private";      var priv...
I've got a class where individual methods may be called statically but will return a new instance of class in order to chain, for example:  var builder = ns   .setState('a', 'A')   .setState('b', 'B');   Where Buil...
Based on my understanding of javascript, prototype methods cannot access variables that are private to the scope of the constructor,   var Foo = function() {       var myprivate = 'I am private';           this.mypublic = 'I am public'...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.