Computer Programming: Are You Ready To Take The JavaScript Quiz!

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Tamoghna
T
Tamoghna
Community Contributor
Quizzes Created: 1 | Total Attempts: 402
Questions: 11 | Attempts: 402

SettingsSettingsSettings
Computer Programming: Are You Ready To Take The JavaScript Quiz! - Quiz

.


Questions and Answers
  • 1. 

    Var a = ""; var b = ['foo', 'max', 'mike']; Make a = "foomaxmike" in a single line of code.

  • 2. 

    If you have seen all the data types in Javascript, then you have seen a new data type in JavaScript called Symbol. Can you tell me what is the use of it?

  • 3. 

    How to delete cookies in JavaScript?

  • 4. 

    Create a function that, given a DOM Element on the page, will visit the element itself and all of its descendents (not just its immediate children). For each element visited, the function should pass that element to a provided callback function. The arguments to the function should be: 1.) a DOM element 2.) a callback function (that takes a DOM element as its argument)

  • 5. 

    Detect the console value of the following line of code. function Foo(a,b,c){ this.x = a; this.y = b; this.z = c; } var m = Foo(3,4,5); var k = {}; Foo.call(k,3,4,5); console.log(k); console.log(m);

    • A.

      {}, {}

    • B.

      {3,4,5}, {}

    • C.

      {3,4,5}, {3,4,5}

    • D.

      {3,4,5}, undefined

    Correct Answer
    D. {3,4,5}, undefined
    Explanation
    The code snippet defines a constructor function `Foo` that takes three arguments `a`, `b`, and `c`. Inside the function, it assigns the values of `a`, `b`, and `c` to the properties `x`, `y`, and `z` of the newly created object using the `this` keyword.

    In the first line after the function definition, `var m = Foo(3,4,5);`, the `Foo` function is called without using the `new` keyword. This means that it is not used as a constructor and does not create a new object. Instead, it simply executes the code inside the function and returns `undefined`. Therefore, `m` is assigned the value `undefined`.

    In the next line, `var k = {};`, a new empty object `k` is created.

    Then, `Foo.call(k,3,4,5);` is called, which executes the `Foo` function with `k` as the `this` value and passes `3`, `4`, and `5` as arguments. This assigns the values `3`, `4`, and `5` to the properties `x`, `y`, and `z` of `k`.

    Finally, `console.log(k);` logs the value of `k`, which is `{3,4,5}`, and `console.log(m);` logs the value of `m`, which is `undefined`.

    Rate this question:

  • 6. 

    How many data types are there in javascript?

    • A.

      5

    • B.

      6

    Correct Answer
    B. 6
    Explanation
    There are six data types in JavaScript. These include number, string, boolean, object, null, and undefined. Each data type is used to store different types of values and has its own set of properties and methods. The number data type is used to store numeric values, the string data type is used to store textual values, the boolean data type is used to store true or false values, the object data type is used to store complex data structures, the null data type is used to represent the absence of any object value, and the undefined data type is used to represent variables that have been declared but have not been assigned a value.

    Rate this question:

  • 7. 

    Var k = {} k[Symbol('lorem')] = "Max"; k[Symbol('lorem')] = "Payne"; console.log(k[Symbol('lorem')]);console value is?

    • A.

      "Max"

    • B.

      "Payne"

    • C.

      Undefned

    Correct Answer
    C. Undefned
    Explanation
    The code creates an empty object `k` and assigns two properties to it using Symbol keys. The first property is assigned the value "Max" and the second property is assigned the value "Payne". When trying to access the value of `k[Symbol('lorem')]`, it will return `undefined` because the Symbol keys are unique and cannot be accessed using any other means except the exact same Symbol key used for assignment. Therefore, the correct answer is "undefined".

    Rate this question:

  • 8. 

    Is  "" == 0?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    The expression "" == 0 is comparing an empty string with the number 0. In JavaScript, when comparing values of different types, the interpreter will try to convert one or both of the values to a common type before making the comparison. In this case, the empty string is converted to a number, resulting in 0. Therefore, the expression "" == 0 is true because both sides of the comparison are equal.

    Rate this question:

  • 9. 

    (function(){ var a = b = 3; })(); console.log(typeof a !== 'undefined'); console.log(typeof b !== 'undefined'); what are console values of above?

    • A.

      True, true

    • B.

      True, false

    • C.

      False, true

    • D.

      False, false

    Correct Answer
    C. False, true
    Explanation
    In the given code, there is a self-invoking function that declares a variable "a" and assigns it the value of 3. However, the variable "b" is not declared with the "var" keyword, so it becomes a global variable. Therefore, "a" is not accessible outside the function and its type is undefined. On the other hand, "b" is accessible globally and its type is not undefined. Hence, the console values are false for the first statement and true for the second statement.

    Rate this question:

  • 10. 

    What is the output of console.log(0.1 + 0.2 == 0.3)?

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    The output of the expression `console.log(0.1 + 0.2 == 0.3)` is `False`. This is because in JavaScript, due to floating point precision, the addition of 0.1 and 0.2 does not result in an exact value of 0.3. Therefore, the comparison `0.1 + 0.2 == 0.3` evaluates to `False`.

    Rate this question:

  • 11. 

    What is console.log(1 && 2);

    • A.

      0

    • B.

      1

    • C.

      2

    • D.

      3

    Correct Answer
    C. 2
    Explanation
    The expression "1 && 2" is evaluated using the logical AND operator. In JavaScript, the logical AND operator returns the value of the second operand if the first operand is truthy (not equal to false, 0, "", null, undefined, or NaN), otherwise, it returns the value of the first operand. In this case, both 1 and 2 are truthy values, so the expression evaluates to 2.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 22, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Nov 14, 2016
    Quiz Created by
    Tamoghna
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.