0% found this document useful (0 votes)
3K views2 pages

ANS:-Var Vikash Undefined Console - Log (Vikash) Null

Question Answer

Uploaded by

Amit Kumar
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)
3K views2 pages

ANS:-Var Vikash Undefined Console - Log (Vikash) Null

Question Answer

Uploaded by

Amit Kumar
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

1. What are the primitive datatype in JS?

ANS :- Primitive data types specify the size and type of variable values. It includes byte ,
short, long, float, double, Boolean and char.

2. What is the difference between a variable that is: null , undefined and undeclared ?

ANS :- Undefined :- It occurs when a variable has been declared but has not been assigned
with any value. Undefined is not a keyword.

Var Vikash;
Undefined
Console.log(Vikash);
Null :- It is a special value that represents an empty or unknown value.
Undeclared :- It occurs when we try to access any variable that is not initialized or declared
earlier.

Console.log(x);

3. What is the difference between do-while and while loop in JS ?

ANS :- Do-while : The do-while statements combo defines a code block to be executed once, and
repeated as long as a condition is true.

The do-while is used when you want to run a code block at least one time.

<script>

let text = “ “ ;

let I = 0;

do {

text += I + “<br>”;

I ++;

while ( I < 5);

document. getElementById (“demo”). innerHTML = text;

</script>

While : The while statement creates a loop that is executed while a condition is true.

The loop runs while the condition is true. otherwise it stops.

<script>

let text = “ ”;
let I = 0;

while (I < 5) {

text += I + “< br >”;

I ++;

document. getElementById (“demo”). innerHTML = text;

</script>

You might also like