Skip to content
Advertisement

Tag: oop

How can I pass a value from Child class to Parent class in JavaScript

I create One Parent class and Two Child classes.Two Child classes each have a method to calculate the value of Area. Whenever I call a7.areaPrint(). It shows me undefined. But I can get the result by c7.calculate() && s7.calculate() in console. How can I pass those two area value to Parent class and Print it? c7.calculate() && s7.calculate() will be

How to visualize JavaScript wrapper objects?

Lately I read that for every primitive data type, a wrapper object is created. It is this wrapper object what makes it possible to use methods with that data, and that makes sense. I also read that functions are objects. I found out that I can visualize the function-as-an-object through console.dir(). However, when I apply console.dir() to a primitive data

JavaScript – Classes are special Functions?

Coming from a Python background, I’ve read this, learning Javascript: Classes are in fact “special functions”, and just as you can define function expressions and function declarations, the class syntax has two components: class expressions and class declarations. on dev.mozilla website.. What I understand is that : Functions are objects in OOP And not classes are functions. And maybe classes

Overriding super method in TypeScript

I’m trying to overload/override a class method in TypeScript, where the superior method takes zero arguments and the subordinate method takes one. My TypeScript code is similar to the following: This code produces the following error: Why doesn’t this work? It it because the transpiled JavaScript output simply isn’t capable of making an inheritance distinction between these two classes? How

How to extend class type with decorator

I’d like to use decorators in my project. Here’s what I have written: As you see this decorators creates a few fields. But typescript can’t recognize them It does exsist though. If I add @ts-ignore before using these parameters, the code works okay. I wounder, how can I create a class decorator, that would extend parent’s type. I tried to

Different output from prototype function and normal function

I’m trying figure out what’s the difference between prototype function and normal function here’s my example: Task is to create function in ‘OOP way’ that will check if string is Uppercased. Why im getting different output? Answer this.toString() will do the trick for you. “” and new String(“”) are different. The this inside the prototype function is an instance of

Advertisement