Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Madelene Campos
    @Madelene
    got it
    perfect
    Joe Crick
    @joe-crick
    OK. Good!
    Madelene Campos
    @Madelene
    thanks :)
    yes!
    Zurc
    @Zurc
    Thanks!
    Joe Crick
    @joe-crick
    Our pleasure :)
    Madelene Campos
    @Madelene
    next week = jQuery Functional Utils
    John Hitz
    @johnhitz
    I'm a bit behind in my js skills...That is I'm probably not intermediate. Do you have any suggestions for background reading I can use to get caught up?
    Madelene Campos
    @Madelene
    @johnhitz I’m basic…so that’s a great question :) (not even intermediate) :)
    John Hitz
    @johnhitz
    I've been following, but info to beef up what your teaching will be great! Thanks!
    Madelene Campos
    @Madelene
    it seems like “this” is directly related to proto/prototypes?
    Madelene Campos
    @Madelene
    this = keyword
    this and new?
    I shouldn’t drink potfulls of coffee whilst trying to understand :)
    yes
    John Hitz
    @johnhitz
    Isn't this where the methods and data of a function live? Similar to self in python?
    Madelene Campos
    @Madelene
    Thanks (I’ll check out that blog)
    so is “this” a placeholder?
    is window the default then?
    John Hitz
    @johnhitz
    Thanks for your time
    Madelene Campos
    @Madelene
    thanks @joe-crick ! clapclapclapclapclap
    ok
    an abstract placeholder :)
    John Hitz
    @johnhitz
    Is it an instance of an object?
    Madelene Campos
    @Madelene
    hehe
    Alexis Abril
    @alexisabril
    blog.bitovi.com
    Madelene Campos
    @Madelene
    Thank you!
    Alexis Abril
    @alexisabril
    thanks everyone for attending!
    John Hitz
    @johnhitz
    Thanks! This is a really great resource!
    OlgaMaraeva
    @OlgaMaraeva
    Thank you!
    OlgaMaraeva
    @OlgaMaraeva
    Maybe i didn't understand the goal of test. http://jsfiddle.net/2ghhrzf4/3/ I need just to call person constructor or set it in NEW constructor? playing whole day but understood nothing:)
    Alexis Abril
    @alexisabril
    @OlgaMaraeva You’re actually pretty close in that example
    you don’t need object.create, but I like where your head’s at

    This line here:

    constructor.applay(ist, Array.prototype.slice.call(arguments, 1)

    Typo in apply ;)

    You do need to invoke the constructor and this line is actually correct, but you can do less. Think about what apply() expects as arguments and what you have available to you.

    OlgaMaraeva
    @OlgaMaraeva
    Oh, thank you a lot @alexisabril! I checked so much but didn't think about mistake in method letters)))) continue thinking
    OlgaMaraeva
    @OlgaMaraeva
    "person is not defined". Can't understand where i lost new http://jsfiddle.net/2ghhrzf4/7/
    Anikeychik Dmitry
    @dima716

    @OlgaMaraeva you forgot to create a Person function constructor that’s why it says «Person is undefined»

    I also corrected a line where you use prototype property for object. You should use instead proto property if you want to set its prototype.

    You can see it here: http://jsfiddle.net/0tLsn27x/1/

    OlgaMaraeva
    @OlgaMaraeva
    @dima716 thank you! I was thinking that i do not need to write person constructor, because of NEW api can do it automatically. If not, why we need the NEW function? Can we simply write the Person function and var smth = new Person('Justin'); to create the class? And i can i also ask for proto property. MDN says that its deprecated. Can i use ist.prototype = Object. create(constructor.prototype) as MDN recommended?
    Anikeychik Dmitry
    @dima716

    @OlgaMaraeva you’re welcome:) About person constructor. It’s not NEW’s responsibility to create a function constructor. When you use NEW or even original new keyword, function constructor had to be created before you use it with new.

    Just try this code var obj = new Person() in console.
    This code won’t work because Person isn’t defined. The same thing with our NEW function.
    Thus, you should manually create function constructor and then use it with NEW or original new keyword.

    Example:

    function Person(name){this.name = name}
    
    var justin = new Person('Justin')
    var david = NEW(Person,['David'])

    About proto property. You’re absolutely right. It’s deprecated and ist.prototype = Object. create(constructor.prototype) is a better option.

    I used proto property just to emphasize that proto and prototype are completly different things.

    OlgaMaraeva
    @OlgaMaraeva
    @dima716 Thank you a lot for this post! I see that NEW function maybe added here to apply properties from constructor. +1 Very good explanation, indeed.
    Justin Meyer
    @justinbmeyer
    @OlgaMaraeva @dima716 Using Object.create or Object.setPrototype is better in code you are writing for an actual application or library
    however, for this example, I think proto is better because I want people to realize that proto is just a "normal" property
    it's only that the DOT(.) and NEW(new) operators treat it differently
    otherwise, setting thing.__proto__ would just be like doing thing.foo
    OlgaMaraeva
    @OlgaMaraeva
    @justinbmeyer Thank you very much for explanation! It's very helpful example. I was confusing because of goal of NEW function. But now i see that it good way to set call or apply methods for inherit properties. Its the main reason we wrote this function instead of simply set var smth = new Person(); Hope i understand well.
    Alexis Abril
    @alexisabril
    hey everyone, we’ll be live momentarily