0% found this document useful (0 votes)
4 views2 pages

JavaScript Question Bank Answers

The document is a JavaScript question bank that includes features of JavaScript, data types, and examples of code. It explains key concepts such as the difference between == and === operators, var and let keywords, and implicit type coercion. Additionally, it provides outputs for various code snippets and answers to specific questions about JavaScript properties and operations.

Uploaded by

swiggyotp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

JavaScript Question Bank Answers

The document is a JavaScript question bank that includes features of JavaScript, data types, and examples of code. It explains key concepts such as the difference between == and === operators, var and let keywords, and implicit type coercion. Additionally, it provides outputs for various code snippets and answers to specific questions about JavaScript properties and operations.

Uploaded by

swiggyotp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

JavaScript Question Bank - Answer Sheet

1. List any four features of JavaScript.


- Lightweight and interpreted.
- Object-oriented.
- Event-driven.
- Platform-independent.
- Supports asynchronous programming.

2. List & explain datatypes in JavaScript.


- Primitive: String, Number, Boolean, Null, Undefined, Symbol, BigInt.
- Non-Primitive: Object, Array, Function, Date, RegExp.

3. Write a JavaScript program to check whether entered number is prime or not.


function isPrime(num) {
if (num <= 1) return false;
for (let i = 2; i <= Math.sqrt(num); i++) {
if (num % i === 0) return false;
}
return true;
}
console.log(isPrime(7)); // true

4. Difference between == and === operators.


- == : Compares value only (type coercion).
- === : Compares value and type (strict equality).

5. Difference between var and let keyword in JavaScript.


- var: function-scoped, hoisted, allows redeclaration.
- let: block-scoped, no redeclaration in same scope.

6. Explain implicit type coercion in JavaScript.


Automatic conversion of values from one type to another (e.g., '5' + 2 = '52').

7. What is NaN property in JavaScript?


NaN means 'Not-a-Number'. It’s returned from invalid math operations (e.g., 0/0).

8. Output of given code.


40
30

9. Output of given code.


10
5

10. Which keyword is used to declare a variable that cannot be reassigned?


const

11. Output of given code.


Hello5

12. Output of given code.


undefined

13. Output of given code.


105

14. Output of ternary operation.


Yes

15. Output of given code.


true

You might also like