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...
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 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'...
I try to override a method and script is:  function wrapper(target) {     target.doABC = function () {         alert('in wrapper');     };     return target; }  function Model() {     wrapper(this); }  Model.prototype.doABC = function () {...
I want to create getter/setter methods dyanmically to retrieve private properties.  This is what I did.  First of all, I made the class:  function winClass (posX, posY, w, h) {   var x = posX || 0;   var y = posY || 0;   var width = w || 0;   var hei...
I've read various "there is no truly private data in Python instances" posts, but we're all aware of using closures in Perl and JavaScript to effectively achieve private data.  So why not in Python?  For example:  import codecs  class...
function Foo() {     var myPrivateBool = false,         myOtherVar;     this.bar = function(myOtherVar) {         myPrivateBool = true;         myOtherVar = myOtherVar; // ?????????????????     }; }   How can I set the private variable myOtherVar?...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.