Advanced Java Script (Ecma Script)
- Java Script is all about objects
- objects are all about properties
- Properties are all about attributes
- Primitive Wrappers
- number ex: new number(125.25)
- boolean
- string(wrapper as a object and give methods and properties)
- Objects
- Literal Form : var obj = {}
- Constructor Form : var obj = new Object()
- Regex
- Literal Form : / /
- Constructor Form : new regExp()
- Array
- Literal Form : [10,20]
- 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
- On Properties (Created Properties)
- Enumerable (can Iterate)
- Data Properties
- Accessor Properties
- Non Enumerable (can't Iterate)
- Data Properties
- Accessor Properties
- Prototype Properties (Primitive values and references of objects)
- Enumerable (can Iterate)
- Data Properties
- Accessor Properties
- Non Enumerable (can't Iterate)
- Data Properties
- Accessor Properties
- Data Properties
Can read and write or can prevent read and write both.- Attributes
- Writable (readOnly : false , writeOnly : true)
- 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
- Configurable
- true : Can Delete Property
- false : Can't Delete Property
- 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)
- Freeze (Writable false,read only)
- Constructor Function (First letter should be capital and use new key word.
- Create an object in heap
- Invoker
- Invoke
- 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;
Can't add or delete but can make changes.
object.seal(Array)
check whether object is sealed or not : object.isSealed(Array)
object.Freeze()
Check whether object is writable or not : object.isFreezable()
Comments
Post a Comment