Loading repository data…
Loading repository data…
surbhidighe / repository
Explore the world of JavaScript through practical output-based questions
Every contribution counts, regardless of its size. I value and appreciate the efforts of all contributors, from beginners to seasoned developers. Join me on this exciting journey of open-source collaboration. Together, let's build something amazing! :handshake:
1. What will be the output
let arr = [1, 2, 3, 4, 5, -6, 7];
arr.length = 0;
console.log(arr);
2. What will be the output
x = 10;
console.log(x);
var x;
3. What will be the output
let a = { x: 1, y: 2 }
let b = a;
b.x = 3;
console.log(a);
console.log(b);
4. What will be the output
for(var i = 0; i < 10; i++){
setTimeout(function(){
console.log("value is " + i);
})
}
5. What will be the output
for(let i = 0; i < 10; i++){
setTimeout(function(){
console.log("value is " + i);
})
}
6. What will be the output
function hello() {
console.log("1");
setTimeout(() => {
console.log("2");
})
console.log("3");
}
hello();
7. What will be the output
let f = "8";
let a = 1;
console.log((+f)+a+1);
8. What will be the output
let a = 10;
if(true){
let a = 20;
console.log(a, "inside");
}
console.log(a, "outside");
9. What will be the output
var a = "xyz";
var a = "pqr";
console.log(a)
10. What will be the output
const arr1 = [1, 2, 3, 4];
const arr2 = [6, 7, 5];
const result = [...arr1, ...arr2];
console.log(result);
11. What will be the output
const person1 = { name: 'xyz', age: 21 };
const person2 = { city: 'abc', ...person1 };
console.log(person2);
12. What will be the output
console.log(5 < 6 < 7);
13. What will be the output
console.log(7 > 6 > 5);
14. What will be the output
console.log(0 == false);
console.log(1 == true);
15. What will be the output
console.log([11, 2, 31] + [4, 5, 6]);
16. What will be the output
console.log({} == {});
console.log({} === {});
17. What will be the output
let x = 5;
let y = x++;
console.log(y);
console.log(x)
18. What will be the output
let x = 5;
let y = ++x;
console.log(y);
console.log(x)
19. What will be the output
console.log('apple'.split(''));
20. What will be the output
const arr = [2,3,5,2,8,10,5];
console.log(arr.indexOf(5))
21. What will be the output
const array = [8, 18, 28, 38];
const result = array.map(element => element + 2)
.filter((element) => element > 25);
console.log(result);
22. What will be the output
function checkValue(value){
var result = Array.isArray(value);
console.log(result);
}
checkValue([1,2,3]);
23. What will be the output
function sum(a=5, b=7){
return a+b;
}
console.log(sum(undefined, 20));
24. What will be the output
console.log(10 + "5");
console.log("5" + 10);