I have some code here. My problem is that I don't manage to understand the way the instance is created. Why we use " : Calculator" ( line 3 ) to use after " new Calculator" (line 4). There is a difference ? I know that I have a problem concerning Typescript but I found this code piece while I was looking for testing in Angular. Also I searched into some tutorials but I don't find explanation.
import { Calculator } from './calculator';
describe('Calculator', () => {
let calculator: Calculator;
beforeEach(() => {
calculator = new Calculator();
});
});
let calculator: Calculatoris specifying that the variablecalculatoris of theCalculatortype.let calculator: Calculatordeclares a variable of typeCalculatoronce, but doesn't assign it.calculator = new Calculator();is called before every test, assigning a newCalculatorfor each test. Because of how jasmine, works, you often docalculator = nullin anafterEachto avoid memory problems;