Advanced Java Script (Ecma Script)

  • Java Script is all about objects

  • objects are all about properties

  • Properties are all about attributes

  • Primitive Wrappers

    1. number ex: new number(125.25)
    2. boolean
    3. string(wrapper as a object and give methods and properties)

  • Objects

    1. Literal Form : var obj = {}
    2. Constructor Form : var obj = new Object()

  • Regex

    1. Literal Form : / /
    2. Constructor Form : new regExp()

  • Array

    1. Literal Form : [10,20]
    2. Constructor Form : new Array[10,20]

  • Iterate Object Properties
    Ex : for(var property in object)

  • Private Variables
    Ex : var _name

  • Variables with use by java script engine
    Ex : var _ _name_ _

  • Change Invoker by using call,apply and bind methods.

  • Object Properties

    1. On Properties (Created Properties)
      • Enumerable (can Iterate)
        1. Data Properties
        2. Accessor Properties
      • Non Enumerable (can't Iterate)
        1. Data Properties
        2. Accessor Properties

    2. Prototype Properties (Primitive values and references of objects)
      • Enumerable (can Iterate)
        1. Data Properties
        2. Accessor Properties
      • Non Enumerable (can't Iterate)
        1. Data Properties
        2. Accessor Properties

  • Data Properties
    Can read and write or can prevent read and write both.
      Attributes
    1. Writable (readOnly : false , writeOnly : true)
    2. Writable should be false when there is a constant

  • Accessor Properties
    Can give access to read only /write only / read and write both.
    Keep value in , EX : _name : "hffe"

  • Property is a collection of set of attributes.

  • Common Attributes
    1. Configurable
      • true : Can Delete Property
      • false : Can't Delete Property
    2. Enumerable
      • true : Appear when iterating
      • false : Doesn't appear when iterating

  • Set attributes to properties
    EX : Object.getOwnDescriptor(myObj,"age");
  • Create new property and replace
    EX : Object.defineProperty(myObj,"property",{descriptor});

  • Stop adding of new properties to the object by using prevent extension
    • Object.preventExtension(Array)
    • Check the extension of the object
      object.isExtensible(Array);

  • Seal Objects (Make configurable false)

  • Can't add or delete but can make changes.
    object.seal(Array)
    check whether object is sealed or not : object.isSealed(Array)
  • Freeze (Writable false,read only)

  • object.Freeze()
    Check whether object is writable or not : object.isFreezable()
  • Constructor Function (First letter should be capital and use new key word.
    1. Create an object in heap
    2. Invoker
    3. Invoke
    4. Return object

    • EX: function Print(){
      console.log(this) // Print{}
      }
      var a = new Print(){};
      console.log(typeOf(a)); // object

  • Replace new Property
    EX : Student.prototype = Object.create(Person.prototype);
    Link Student to the prototype
    Student.prototype.constructor = Student;

Comments

Popular posts from this blog