JavaScript Assessment

JavaScript Assessment

  1. What is the correct way to declare a variable in JavaScript?

    a) var x = 10; b) variable x = 10; c) let x = 10;
  2. What will be the output of the following JavaScript code snippet?

                            var x = 10;
                            console.log(typeof x);
                            x = "hello";
                            console.log(typeof x);
                        
    a) number and string b) string and number c) number and number
  3. Which of the following loops is used for iterating over the properties of an object in JavaScript?

    a) for b) while c) for...in
  4. Which JavaScript block is used for error handling and recovery in a program?

    a) try b) catch c) finally
  5. What is the keyword used in JavaScript to throw an exception manually?

    a) throw b) try c) error
  6. Which JavaScript method is used to parse a string and return a JavaScript object?

    a) parseJSON b) stringify c) toJSON
  7. In which language is JavaScript primarily implemented?

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

                            var a = [1, 2, 3];
                            var b = a;
                            b[0] = 5;
                            console.log(a);
                        
    a) [1, 2, 3] b) [5, 2, 3] c) [1, 2, 3, 5]