1

I've been doing some experiments about high-order functions and decided to understand how to make an custom addEventListener function so to understand what's under the hood.

enter image description here

As you can see, it requires an 'event' parameter, but even though I'm not supplying at the second function, it works..

But here:

enter image description here

Yes, I get it, in vanilla JS the second function also works and coordinates gets undefined, but in this TypeScript code, first one works, second not.. I'm just confused.

Also, what's the right way to make an function's parameters optional, either insert params or empty.

Thanks for your time.

Edit: I think I'm looking for some kind of method overload like in java

public void someFunc(int a, int b)
public void someFunc(int a)
public void someFunc()

What's the equilavent of this in Js?

7

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.