Димитар Георгиев

functions and all other identifiers—primitives and objects.

Speakings 0 комментариев
functions and all other identifiers—primitives and objects.
  • # scripts
    functions and all other identifiers—primitives and objects.
    literals such
    as object,array, and regular expression literals
    objects in JavaScript = key - value /*  hash tables of key - value pairs */
    The values can be properties = primitives /* number, string, boolean,
    null, and undefined values */ or other objects; 
    The values can also be functions in which case they are called methods.
    methods, should go to the prototype.
    Many of the properties of the built-in native objects are also mutable.
    Objects are simply mutable hashes
    Object() constructor accepts a parameter  depending on the value passed, it may
    decide to delegate the object creation to another built-in constructor and
    return a different object 
    constructors are still just functions but invoked with new
    are not objects but, the primitive is temporarily converted to an object behind 
    the scenes and behaves as if it
    were an object.
    Functions are objects that have their own properties and methods.
    Functions provide
    scope! When you think of a function in JavaScript, think
    of an object,
    be executed
    Function declarations can only appear in “program code,” meaning inside of the
    bodies of other functions or in the global space.  The name property is 
    also used to call the same function recursively from 
    within itself
    function expressions is highlight that functions are objects like all other objects
    a function declaration, the definition of the function also gets hoisted, not 
    only its declaration.  Function bar() only its declaration gets hoisted, the
    definition of bar() is not hoisted  === only variable 'bar' gets hoisted not the implementation.
    Public static member, which can be used without having to create an instance of the 
    class. There can also be private static members—not visible to the consumer 
    of the class but still shared among all the instances of the class.
    The goal of implementing classical inheritance is to have objects created by 
    one constructor function Child() get properties that come from another constructor
    Prototype property  has to point to an instance (an object) created with the parent 
    constructor, not to the constructor itself
    Using constructor functions looks like using classes in Java. They also enable 
    you to add instance properties to this inside of the constructor body. However,
    adding methods to this is inefficient, because they end up being re-created 
    with every instance and hat consumes more memory.That’s why reusable
    methods should be added to the prototype property  of the constructor  
    Classical Pattern #3—Rent and Set Prototype : The benefit is that the result 
    objects inherit everything there is in the parent, and at the same time it’s 
    safe to modify own properties without the risk of modifying the parent
    The rule of thumb was that reusable members should go to the prototype and 
    not this
    Classical Pattern #5 :  You have an empty function F(), which serves as a 
    proxy between the child and the parent F()’s prototype property points to 
    the prototype of the parent.  In this pattern, any members that the parent constructor 
    adds to this are not inherited, here the child only inherits properties of
    the prototype.
    Inheritance by Copying Properties : In this pattern, an object gets 
    from another object, simply by copying it.
    With the shallow copy (because objects are passed by reference in JavaScript), 
    if you change 
    a property of the child, and this property happens to be an object, then you’ll
    be modifying the parent as well Mix-ins :  Instead of copying from one object, you 
    can copy from any number of objects and mix them all into a new object.
  • Functions in JavaScript are objects, and they come with some interesting 
    methods of their own, such as call() and apply(). The only difference 
    between the two is that one takes an array of parameters to be passed to the 
    method being called, and the other one takes parameters one by one.


Назад Вперед
Войдите или зарегистрируйтесь
чтобы оставить комментарий