Advanced JavaScript - Chapter 10 - JavaScript - new Keyword

preview_player
Показать описание
new Keyword in JavaScript:
We know that we can create an object using new Keyword.

The new keyword performs following four tasks:
It creates new empty object e.g. obj = { };
It sets new empty object's invisible 'prototype' property to be the constructor function's visible and accessible 'prototype' property.
It binds property or function which is declared with this keyword to the new object.
It returns newly created object unless the constructor function returns a non-primitive value. If constructor function does not include return statement then compiler will insert 'return this;' implicitly at the end of the function. If the constructor function returns a primitive value then it will be ignored.

new Keyword in JavaScript:
new Keyword in JavaScript:
new Keyword in JavaScript:
new Keyword in JavaScript:
new Keyword in JavaScript:
new Keyword in JavaScript:

ankpro
ankpro training
C#
C sharp
Bangalore
Rajajinagar
Selenium
Coded UI
Mobile automation testing
Mobile testing
JQuery
JavaScript
.Net
Components of the .Net framework
Рекомендации по теме
Комментарии
Автор

How can i access property of object if add property using defineProperty

1. function Demo(){var myVar = 1; this.x = 100;}
2. var obj1 = new Demo();
3. Object.defineProperty(Demo, 'z', {value:400});
4. console.log('Z-->', obj1.z);

maheshbabuBokkisam
welcome to shbcf.ru