Java script Objects overview
Java script – Objects overview
Java script is object oriented programming language. It has the following object oriented concepts such as,
- Encapsulation
- Polymorphism
- Inheritance
- Aggregation
16.1 Encapsulation
Encapsulate means capsule is covered with layer. Likewise encapsulation is putting data and method into a single container known as object. Many instances can be taken from the object.
16.2 Polymorphism
Polymorphism means many ways such as same method or function is used for multiple purpose.
16.3 Inheritance
The task of getting properties from their ancestors is called as inheriting.
16.4 Aggregation
The task of nesting more than one object is known as aggregation.
16.5 Object Properties
In object oriented programming paradigm each entity is referred to as objects. Objects have properties and methods. Property values decide the appearance of the object.
Syntax for accessing property of object
In the above two examples document is the object name. title and cookie are the properties of the object document.
16.6 Object methods
Methods are functions to perform operations on the properties of the object.
Syntax:
Explanation:
document is the object name and write is the method name to display content on the current document.
16.7 User defined objects
An object is an instance of user defined variable. The user defined object has two parts such as data and methods.
The new operator
new is the keyword (or) operator to create objects.
Object() constructor
Constructor is also one of the method to derive objects. It is followed by the keyword new.
Example:
![Java Script Objects Overview java script objects overview img1](https://www.assignmenthelp.net/webimg/ahp/javascript-assignment-help/java-script–objects-overview-img1.jpg)
16.8 Accessing properties using this keyword
Syntax:
![Java Script Objects Overview java script objects overview img1](https://www.assignmenthelp.net/webimg/ahp/javascript-assignment-help/java-script–objects-overview-img4.png)
Example
![Java Script Objects Overview java script objects overview img2](https://www.assignmenthelp.net/webimg/ahp/javascript-assignment-help/java-script–objects-overview-img2.jpg)
16.9 Assigning functions as object’s methods
Object has two parts such as properties and methods. The following example illustrate how the function work as method for object.
![Java Script Objects Overview java script objects overview img3](https://www.assignmenthelp.net/webimg/ahp/javascript-assignment-help/java-script–objects-overview-img3.jpg)
Explanation:
function ‘per’ is created with one argument named as percentage. Object student is constructed using ‘new’ operator.
Object_name.function_name(argument_value);
The above syntax is used to assign values for the arguments of the function per.
Using ‘this’ pointer that function is assigned as object’s one of the property.
this.function_name=function_name;
16.10 With key word in java script
The keyword is for Accessing properties and methods of object without specifying object name and (.) operator.
Example program:
![Java Script Objects Overview java script objects overview img1](https://www.assignmenthelp.net/webimg/ahp/javascript-assignment-help/java-script–objects-overview-img5.png)
Output:
Student rollno : 100
Name is : Lakshmi
Percentage is : 98
- Namespaces
- Preprocessor Directives
- Regular Expressions
- Exception Handling
- File I/O
- Attributes
- Reflection
- Properties
- Indexers
- Delegates
- Events
- Collections
- Generics
- Anonymous Methods
- Unsafe Code
- Multithreading
- Variables Declarations
- Build In Types
- Operators
- Unary Operators
- Binary Operators
- Array Operations