Find output of following code
1) var arr = [1,2,3]
console.log(arr)
output:
[ 1, 2, 3 ]
2) var arr1={
"a":1,
"b":2,
"c":3
}
console.log(arr1);
output:
{ a: 1, b: 2, c: 3 }
3) var func = function(a,b){
return a+b;
}
console.log(func);
output:
[Function: func]
4) var obj ={
add:function(a,b){
return a+b
},
substract:function(a,b){
return a-b;
}
}
console.log(obj);
output:
{ add: [Function: add], substract: [Function: substract] }
5) for(a in arr1){
console.log(a);
}
output:
a
b
c
6) for(a in arr){
console.log(a);
}
output:
0
1
2
7) for(a of arr){
console.log(a);
}
output:
1
2
3
8) var c = 3 in arr
console.log(c);
output:
false
9) var fruits = ["Banana", "Orange", "Apple", "Mango"];
var n = fruits.includes("Mango");
console.log(n);
output:
true
10) var d ={
add:function (y){
var x=5;
function add1(x,y){
return x+y;
}
return add1;
}
}
console.log(d);
output:
{ add: [Function: add] }
11) can we have func(a)(b) in javascript
function space(a) {
let b = function (c) {
return a+c;
}
return b;
}
var t = space(7)(6)
console.log(t);
output:13
1) var arr = [1,2,3]
console.log(arr)
output:
[ 1, 2, 3 ]
2) var arr1={
"a":1,
"b":2,
"c":3
}
console.log(arr1);
output:
{ a: 1, b: 2, c: 3 }
3) var func = function(a,b){
return a+b;
}
console.log(func);
output:
[Function: func]
4) var obj ={
add:function(a,b){
return a+b
},
substract:function(a,b){
return a-b;
}
}
console.log(obj);
output:
{ add: [Function: add], substract: [Function: substract] }
5) for(a in arr1){
console.log(a);
}
output:
a
b
c
6) for(a in arr){
console.log(a);
}
output:
0
1
2
7) for(a of arr){
console.log(a);
}
output:
1
2
3
8) var c = 3 in arr
console.log(c);
output:
false
9) var fruits = ["Banana", "Orange", "Apple", "Mango"];
var n = fruits.includes("Mango");
console.log(n);
output:
true
10) var d ={
add:function (y){
var x=5;
function add1(x,y){
return x+y;
}
return add1;
}
}
console.log(d);
output:
{ add: [Function: add] }
11) can we have func(a)(b) in javascript
function space(a) {
let b = function (c) {
return a+c;
}
return b;
}
var t = space(7)(6)
console.log(t);
output:13
No comments:
Post a Comment