TypeScript Assessment

TypeScript Assessment

  1. How do you declare a variable in TypeScript?

    a) var x = 10; b) let x = 10; c) const x = 10;
  2. What is the output of the following TypeScript code snippet?

                            let x: number = 10;
                            console.log(typeof x);
                            x = "hello";
                            console.log(typeof x);
                        
    a) number and string b) string and number c) number and any
  3. Which TypeScript loop is used to iterate over the elements of an array?

    a) for b) while c) for...of
  4. In TypeScript, what is used to handle error conditions and exceptions?

    a) try b) catch c) throw
  5. What keyword is used in TypeScript to specify the type of a variable?

    a) type b) typeof c) as
  6. Which TypeScript module is used for date and time operations?

    a) Date b) datetime c) moment
  7. In which programming language is TypeScript primarily implemented?

    a) JavaScript b) Java c) TypeScript
  8. What will be the output of the following TypeScript code?

                            let a: number[] = [1, 2, 3];
                            let b: number[] = a;
                            b[0] = 5;
                            console.log(a.join(" "));
                        
    a) 1 2 3 b) 5 2 3 c) 1 5 3