Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Chris Klanac
    @cklanac
    But the proto object(s) can also have properties so a puppy has a spine (like the in the examples) which can be looked up on the proto
    You can use hasOwnProperty() to check if the property is on the specific object or looked up in the proto chain
    Emmanuel Hernandez
    @ManuH
    hey guys, I have a question about the exercise, the function "hasOwnProperty" is already defined?
    Alexis Abril
    @alexisabril
    @ManuH Yep. “hasOwnProperty” is a method that exists on the Object.prototype.
    Lotfi Harrabi
    @lotfire
    @ManuH yes
    Emmanuel Hernandez
    @ManuH
    nice, thanks
    Emmanuel Hernandez
    @ManuH

    module('new, dot, and dotcall');
    test('DOT', function(){
    var person = new Person('Alexis');
    var species = DOT(person, 'species');
    equal(species, 'Homo Sapien', 'property accessed');

    what is 'equal'?

    Alexis Abril
    @alexisabril
    @ManuH equal, deepEqual and ok are all QUnit assertion methods. We have a set of tests in the html just to validate the exercises
    Emmanuel Hernandez
    @ManuH
    cool thanks
    Alexis Abril
    @alexisabril
    np!
    Emmanuel Hernandez
    @ManuH
    I'm still trying to do the DOTCALL
    but I don't get what's supposed to do
    Alexis Abril
    @alexisabril

    @ManuH DOTCALL simulates invoking a method on an object. For example:

    person.speak(); //invokes the speak method, which may exist anywhere on the prototype, but uses “person” as “this”.

    DOTCALL(person, ‘speak’); //will do the same as above

    Imanuel Gittens
    @imanuelgittens
    Hi guys. I'm learning a lot from your training.
    You're awesome
    I'm trying to make the DOT function and I wanted some direction.
    I'm thinking that to walk the proto chain, there must be some kind of loop involved
    however i don't know when that loop should end
    should it end when proto is equal to the window object?
    Imanuel Gittens
    @imanuelgittens
    DOT = function(obj, prop) {
    
                if (obj.hasOwnProperty(prop)) {
                    return obj[prop];
                } else {
    
                    var parent = obj.__proto__;
                    if(parent.hasOwnProperty(prop){
                        return parent[prop];  
    
                    }
                }
            }
    That's what I have so far
    Imanuel Gittens
    @imanuelgittens
    DOT = function(obj, prop) {
    
                if (obj.hasOwnProperty(prop)) {
                    return obj[prop];
                } else {
                    return DOT(obj.__proto__, prop);
                }
    
            };
    or maybe my second code snippet might work?
    thanks
    Alexis Abril
    @alexisabril
    hey everyone! we’ll get started shortly
    to recap last week’s exercises: http://jsbin.com/yamuna/latest/watch?js,output
    we’ll tackle that first
    Imanuel Gittens
    @imanuelgittens
    I was really close to solving last week's exercise.
    I forgot to check if the object existed
    Joe Crick
    @joe-crick
    Nice!
    Zurc
    @Zurc
    You said that you're setting proto but using prototype?
    yes
    John Hitz
    @johnhitz
    So proto is just the link or pointer to the prototype?
    sorry that's proto
    Joe Crick
    @joe-crick
    @Zurc: Was your question answered?
    Zurc
    @Zurc
    I think I understood, still another question: Do we use proto in our code at all?
    thanx!
    Joe Crick
    @joe-crick
    NP!
    Madelene Campos
    @Madelene
    same here
    (thanks for repeating) :)
    Joe Crick
    @joe-crick
    :)
    John Hitz
    @johnhitz
    Can you show that in the terminal
    Joe Crick
    @joe-crick
    Are you asking to have the exercise shown in the terminal?
    John Hitz
    @johnhitz
    Not using a different this for each dog1, dog2, and pup
    Joe Crick
    @joe-crick
    @johnhitz Do you mean how to fix the example?
    of the shared pup value?
    John Hitz
    @johnhitz
    Yes
    Imanuel Gittens
    @imanuelgittens
    Maybe you could just once over the slide with dog1, dog2, and pup?
    Thank you
    Joe Crick
    @joe-crick
    Sure thing!