Thanks to visit codestin.com
Credit goes to www.scribd.com

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

Question

nbjnbj

Uploaded by

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

Question

nbjnbj

Uploaded by

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

1.

const shape = {
radius: 10,
diameter() {
return this.radius * 2;
},
perimeter: () => 2 * Math.PI * this.radius,
};

console.log(shape.diameter());// 20
console.log(shape.perimeter());// will print value of 2*3.14*10
-----------------------------------------------------------------------------------
-------------------------------
2.
let obj = {
x: 2,
getX: function() {
setTimeout(() => console.log('a'), 0);//
new Promise( res => res(1)).then(v => console.log(v));//
setTimeout(() => console.log('b'), 0);//
}
}

obj.getX(); // 1.) value of v 2.) a, 3.) b


-----------------------------------------------------------------------------------
----------------------------------

3.
var a = 10;
function abc(){
console.log(a);//
var a = 20;
console.log(a);//
}
console.log(a);// 10
abc();// 10, 20
---------------------------------------------------------------------

4.
var a = {'key': 100};
var b = []
b[a] = 90;
console.log(b);// error
----------------------------------------------------------------------------
5.
var a = 50;
var b = { name : 'abc' };
function abc(a,b){
console.log(a,b);//. 50, name : 'abc'
b.name = 'cde';
console.log(a,b);// 50, name : 'cde'
}
abc();// 1.) undefined a, undefined b
abc(a,b);// 50, name : 'abc', 2.) name : 'cde'
console.log(a,b);// 50, name : 'abc'
-------------------------------------------------------------------------------

6.
unction foo() {
let a = b = 0;
a++;
return a;
}
foo();
console.log(typeof a); // int
console.log(typeof b); // int

-----------------------------------------------------------------------------------
--------------
7.
let a =10
{
var a = 20
}

console.log(a);// 10
----------------------------------------------------------

8.

Promise.resolve(1)
.then((x) => x + 1)
.then((x) => { throw new Error('My Error') })
.catch(() => 1)
.then((x) => x + 1)
.then((x) => console.log(x)) // no idea
.catch(console.error)

You might also like