Exploring TypeScript Interfaces: Methods vs. Function Properties

Exploring TypeScript Interfaces: Methods vs. Function Properties

Typescript, as a superset of JavaScript, enhances JavaScript’s capabilities, including the way we define object structures. We’re going to delve into a common misconception: What’s the difference between method signatures and function property definitions in TypeScript interfaces? We’ll break it down with some examples, and explain the subtle differences between these two ways of declaring a method in an interface: 1interface MyInterface { 2 myMethod(): void; // method 3 myMethod: () => void; // function 4} Defining methods in interfaces In Object-Oriented Programming (OOP), methods are the behaviours classes....

January 9, 2024 · 4 min
Difference between var, const and let

Difference between var, const and let

There are 3 ways to declare a variable in Javascript: using one of the keywords var, const or let. Prior to ES6, var used to be the only way to declare a variable. You had no other choice. However, it had some weird and unexpected behavior, which often resulted in hard to debug errors. Intuitively, you would think variable declared with var is block scoped. Variable declared in, for example, if statement, or a for loop, is visible only in the scope of that statement or loop....

May 6, 2020 · 3 min