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

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Tamoghna
T
Tamoghna
Community Contributor
Quizzes Created: 1 | Total Attempts: 409
| Attempts: 409 | Questions: 7
Please wait...
Question 1 / 7
0 %
0/100
Score 0/100
1. How many data types are there in javascript?

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.

Submit
Please wait...
About This Quiz
Computer Programming: Are You Ready To Take The JavaScript Quiz! - Quiz

Dive into JavaScript with this engaging quiz! Test your skills on object manipulation, string operations, understanding of data types, and the unique use of Symbols in JavaScript. Perfect... see morefor learners looking to validate their JavaScript knowledge and enhance their programming capabilities. see less

2. Is  "" == 0?

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.

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

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".

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

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`.

Submit
5. What is console.log(1 && 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.

Submit
6. 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);

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`.

Submit
7.
(function(){ 
var a = b = 3; 
})(); 

console.log(typeof a !== 'undefined'); 
console.log(typeof b !== 'undefined'); 
what are console values of above?

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.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 22, 2023 +

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
Cancel
  • All
    All (7)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
How many data types are there in javascript?
Is  "" == 0?
Var k = {} ...
What is the output of console.log(0.1 + 0.2 == 0.3)?
What is console.log(1 && 2);
Detect the console value of the following line of code. function...
(function(){ ...
Alert!

Advertisement