TypeScript'te Değerleri Değiştirme

Diyelim ki bir string değişkenimiz var:

typescriptlet test: string = 'abc';

Şimdi ona farklı bir string değer atayalım:

typescriptlet test: string = 'abc';
test = 'def';

Şimdi ona bir sayı atamayı deneyelim. Bu durumda TypeScript hata verecektir, çünkü değişkenin türünü değiştirmeye çalışıyoruz:

typescriptlet test: string = 'abc';
test = 123; // hata verecek
Задание 1

Kodu çalıştırmadan, kodun çalıştırılması sonucunun ne olacağını belirleyin:

typescriptlet test: number = 123;
test = 'abc';

console.log(test);
Задание 2

Kodu çalıştırmadan, kodun çalıştırılması sonucunun ne olacağını belirleyin:

typescriptlet test: string = 'abc';
test = 123;

console.log(test);
Задание 3

Kodu çalıştırmadan, kodun çalıştırılması sonucunun ne olacağını belirleyin:

typescriptlet test: string = 'abc';
test = '123';

console.log(test);
Задание 4

Kodu çalıştırmadan, kodun çalıştırılması sonucunun ne olacağını belirleyin:

typescriptlet test: string = 'abc';
test = true;

console.log(test);
Задание 5

Kodu çalıştırmadan, kodun çalıştırılması sonucunun ne olacağını belirleyin:

typescriptlet test: string = 123;
test = 'abc';

console.log(test);
Задание 6

Kodu çalıştırmadan, kodun çalıştırılması sonucunun ne olacağını belirleyin:

typescriptlet test: string = '123';
test = '456';

console.log(test);
Задание 7

Kodu çalıştırmadan, kodun çalıştırılması sonucunun ne olacağını belirleyin:

typescriptlet test: number = '123';
test = '456';

console.log(test);
Задание 8

Kodu çalıştırmadan, kodun çalıştırılması sonucunun ne olacağını belirleyin:

typescriptlet test: number = 123;
test = 456;

console.log(test);
Задание 9

Kodu çalıştırmadan, kodun çalıştırılması sonucunun ne olacağını belirleyin:

typescriptlet test: boolean = true;
test = false;

console.log(test);