JavaScript Interview Output Questions

                JAVASCRIPT INTERVIEW QUESTIONS
                


1, what is the output:
let a=[];
let b=[];
console.log(a==b);
console.log(a===b);

Ans:  false false

2. what is the output:
let a=[1,2,3,4];
console.log(...a);

Ans: 1 2 3 4


3. what is the output:
let a=3;
let b='3';
console.log(a==b);
console.log(a===b);

Ans: true  false


4. what is the output:
let a=[1,2,3];
let b=[4,5,6,...a];
console.log(b);

Ans: [4,5,6,1,2,3]

5. what is the output:
console.log(typeof(NaN));

Ans: number



6. what is the output:
let a = 20 - - 20;
console.log(a);

Ans: 40


7.what is the output:
 const person ={
 name:'guru',
 city:'Delhi',
 }
 console.log(delete person);

Ans: false


8. what is the output:
 const arr = ['amit', 'aman', 'shubham'];
        const [x, y, z] = arr;
        console.log(x);
        console.log(y);
        console.log(z);


Ans: amit aman shubham


9. what is the output:
 const arr = ['amit', 'aman', 'shubham'];
        const [x,, z] = arr;
        console.log(x);
        console.log(z);


Ans: amit shubham


10. what is the output

 let person = {
            name: 'Rishabh',
            surname: 'Sharma'
        }
        let info = {
            city: 'delhi',
            country: 'India'
        }
        person = { ...person, ...info };
        console.log(person);
Ans. {
  1. city: "delhi"
  2. country: "India"
  3. name: "Rishabh"
  4. surname: "Sharma"
}

11. what is the output

       function getData() {
            console.log(data);
            let data = 'delhi';
        }
        getData();

Ans:Uncaught ReferenceError: Cannot access 'data' before initialization

12. what is the output:

 let data = ['delhi', 'harayana', 'chandigarh'];
        delete data[1];
        console.log(data);
        console.log(data.length);

Ans: ['delhi', empty, 'chandigarh']    
          3

13.what is the output:
 console.log(undefined==null);
Ans. true


14. what is the output:

 console.log(undefined===null);
Ans. false

15. what is the output:
 console.log(a);
    var a;
Ans. undefined

16. what is the output:
    let a = 1;
    let b = 1;
    let c = 2;
    console.log(a === b === --c);
Ans.

Comments