Objects are very important data type in JavaScript. They may be made of any specific or non-specific group of data types and functionality.
Objects can be created more then one way, here are two most common:
Object initialization:
var obj = {property1: value1, property2:value2, ….. property:valueN};
Constructor function:
function objConstructor(arg1, arg2, arg3){
// properties...
// methods...
}
var obj = new objConstructor(arg1, arg2, arg3); //Creating object using constructor.
Object constructor defines object's own properties and methods (functions) that developer choses specially for that object or group of objects. The pre-defined or integrated methods and properties are listed below.
NAME | DESCRIPTION |
---|---|
abstraction | Abstraction refers to declaring methods and hiding their implementation |
class | Classes in JavaScrtipt don't exist and are replaced with constructor functions. |
constructor | Constructor is a function (or a method) that initiates new object's instance with common properties and methods. |
encapsulation | Ensures that the private constructor data defined with var (not this) keyword is / are available only within that object. |
inheritance | Inheritence refers to properties and methods inherited from a parent object by another initialized object. |
method | Methods are functions defined inside a constructor and initialized when an instance is created. They are frequently used to define actions on the properties. |
namespace | Identifiers, methods and functions under specific name. |
object | Object as an instance of a constructor and is created with keyword new |
polymorphism | A function defined in a parent constructor with various implementations. |
property | Properties are variables defined inside a constructor and initialized when an instance is created. |
PATTERN | DESCRIPTION |
---|---|
constructors | Creats an instance object from the constructor with the keyword new. |
factory pattern | Creats an instance object at run-time, without using keyword new. |
listed patterns | Creats an object with name-value pairs within {} brackets. |
prototypes | Creates an object from new Object() instance and allows changing the inherited properties and metho |
PROPERTY | DESCRIPTION |
---|---|
combination inheritance | Combination of prototpye chaining to inherit properties and methods constructor inheritance. |
constructor / prototypes combination | Efficient way of creating objects by making instances with a constructor and shared methods and properties with prototypes. |
constructor inheritance | Inherited properties and methods from the parent instance. |
dynamic prototype pattern | The protoype inside a constructor gets initialized only if needed making the data encapsulated and code simpler. |
parasitic constructor pattern | A constructor creates and object and returns the object. |
prototype chaining | Linking of object's prototypes till reaching the main parent object and while implementing inheritence.. |
prototypal inheritance | An empty constructor thate returns another constructor as a new instance of the object. |
METHOD | DESCRIPTION |
---|---|
create() | Creates an object with specific prototype. |
defineProperty() | Defines the type of a prototypes property. |
getPrototypeOf() | Determines a prototype of an object. |
hasOwnProperty() | Checks for a property's existance. |
isPrototypeOf() | Checks if the object is a prototype of another object. |
propertyIsEnuIerable() | Checks if given property can be enumerated. |
setPrototype() | Sets a prototype of an object. |
toLocaleString() | Returns a string representation of the object that is appropriate for the local charset. |
toString() | Returns a string representation of the object. |
valueOf() | Returns a string, number, or Boolean equivalent of the object. |
PROPERTY | DESCRIPTION |
---|---|
__proto__ | Default inherited property that allows reading and writing to the prototype property. |
in | Checks for a property in a specified object. |
instanceof | Checks the type of the instance an object was created from. |
prototype | Default inherited property from a constructor that encapsulate all internally defined properties and methods. |
Comments
No comments have been made yet.
Please login to leave a comment. Login now