How to create Objects using JavaScript Object Constructor - JavaScript Tutorial 78

preview_player
Показать описание
Notes for You:: How to Create Objects using JavaScript Object Constructor - Tutorial 78
- If we want to create multiple objects of same type, then we take help of constructor function
- Constructor function helps us to define a constructor for any object type.

Object type [class]
- is a combination of its constructor and its prototype.

Constructor:
- is a special function responsible for constructing new object and called as soon as a new object is created.

Prototype:
- is a special object contains shared properties and behaviors of instances.

Example:
- Rectangle : object type
- rect1,rect2 … : objects or instances of Rectangle object type
- function Rectangle(width,height){ }: constructor function for Rectangle object type

Syntax:
// Defining a constructor function
function ObjectTypeName( [value1, value2, …. ]) {

}

// Creating new objects
var objectName = new ObjectTypeName ([param_list]);

Example Code:
// Definition of constructor function for Rectangle type
function Rectangle(width,height) {
{
};
}
// Creating new rect1 object using Rectangle type
var rect1 = new Rectangle(5,5);

=========================================

Follow the link for next video:
JavaScript Tutorial 79 - this Keyword in JavaScript | JavaScript this Keyword

Follow the link for previous video:
JavaScript Tutorial 77 - Constructor Functions in JavaScript | JavaScript Constructor Functions

=========================================

JavaScript Tutorials Playlist:-

=========================================
Watch My Other Useful Tutorials:-

jQuery Tutorials Playlist:-

jQuery UI Tutorials Playlist:-

Bootstrap Tutorials Playlist:-

=========================================

► Subscribe to our YouTube channel:

► Visit our Website:

=========================================
Hash Tags:-
#ChidresTechTutorials #JavaScript #JavaScriptTutorial
Рекомендации по теме
Комментарии
Автор

SUBSCRIBE, SHARE & SUPPORT:
VISIT & LEARN AT FREE OF COST:

ChidresTechTutorials
Автор

Thanks a lot, sir. very nicely explained!

mukeshgarg
Автор

Hello Sir,
Great explain, please upload more videos about advance oop concepts like promises, lexical scope and closures etc...
Thanx for sharing

qasimbutt
welcome to shbcf.ru