From d8ae2e470354e291a022eb94a8ecb2f7c610645f Mon Sep 17 00:00:00 2001 From: usmanashrf <45431758+usmanashrf@users.noreply.github.com> Date: Sat, 28 Jan 2023 14:34:35 +0500 Subject: [PATCH] add some details in step 13c Constructor --- step13c_constructor/app.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/step13c_constructor/app.ts b/step13c_constructor/app.ts index 402bd1ae..c9f60641 100644 --- a/step13c_constructor/app.ts +++ b/step13c_constructor/app.ts @@ -1,5 +1,7 @@ -// If parent class provide constructor(with or without argument) then you must have to create constructor in child class -// and must call super() +// If parent class provide constructor(with or without argument) +// then you must have to create constructor in child class and must call super() +//If you want to initialize the members of the child class differently than the parent class. +//otherwise If the child class does not define its own constructor, it will inherit the constructor of the parent class. // Below code will not work because it does not call super, // Case 1: @@ -61,7 +63,10 @@ class F extends E { console.log("F constrcutor"); super(theName,4); // Must call super with two arguments - //super("Hello",5); // Multiple supper call working, No error here -- seems to be some special case + //super("Hello",5); + // Multiple supper call working, No error here -- seems to be some special case + // but when we'll run this code it'll give us "ReferenceError: Super constructor may only be called once" + } } let e: E = new E("E",1);