Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #23050

Re: Cons in the following object implementation

Newsgroups comp.lang.javascript
Subject Re: Cons in the following object implementation
From "Evertjan." <exxjxw.hannivoort@inter.nl.net>
References <76619944-f726-4102-a16c-0eceddb251a0@googlegroups.com>
Date 2014-02-10 13:33 +0100
Message-ID <XnsA2D089FF5B476eejj99@194.109.133.133> (permalink)

Show all headers | View raw


Alon Melanker <melankeril@gmail.com> wrote on 10 feb 2014 in
comp.lang.javascript: 

> On a job interview, I've been asked to defined an object with a private
> variable and getter/setter for this private variable. 
> 
> I chose the following:
> 
> var obj = function() {
>    var private;
>    
>    this.setPrivate(val) {
>       private = val;
>    }
>    
>    this.getPrivate() {
>       return private;
>    }
>};

Didn't you ask this before?

> When I've finished to implement the object the interviewer told me there
> are some problems\cons with this object and those "problems" are not the
> setter/getter functions. 
> 
> I've been asked to point out those flaws, but I couldn't.
> 
> Does anyone can point out the flaws in the object?  

<http://stackoverflow.com/questions/11258201/what-does-this-mean-in-
javascript-var-obj-function>


-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Cons in the following object implementation Alon Melanker <melankeril@gmail.com> - 2014-02-10 04:21 -0800
  Re: Cons in the following object implementation "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-02-10 13:33 +0100
    Re: Cons in the following object implementation Alon Melanker <melankeril@gmail.com> - 2014-02-10 05:22 -0800
  Re: Cons in the following object implementation Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-02-10 14:53 +0100

csiph-web