TypeScript Problem Solving Questions
console.clear();
function Foo() {
this.bar = 10;
}
Foo.prototype.bar = 42;
var foo = new Foo();
console.log("1:", foo.bar);
delete foo.bar;
console.log("1:", foo.bar);
// OUTPUT OF CODE
// [LOG]: "1:", 10
// [LOG]: "1:", 42
const x = [1,2,3];
x[-1] = -1;
console.log(x[x.indexOf(10000)]);
// OUTPUT OF CODE
// [LOG]: -1
let index1:number = 1;
function tutest() {
let index2:number = 2;
if(index2 > index1) {
let index3:number = 3;
index3++;
}
while(index1 < index2) {
let index4:number = 4;
index1++;
}
console.log(index1);
console.log(index2);
console.log(index3);
console.log(index4);
}
tutest();
// OUTPUT OF CODE
//[LOG]: 2
//[LOG]: 2
//[ERR]: "Executed JavaScript Failed:"
//[ERR]: index3 is not defined
use https://www.typescriptlang.org/play/?#code/Q