What will be the output of the following JavaScript code? [code] var obj= { length:20, height:35, } if (‘breadth' in obj === false)

What will be the output of the following JavaScript code?
Code:
var  obj=
{
	length:20,
	height:35,
}
if (‘breadth' in obj === false) 
{
  	obj.breadth = 12;
}
console.log(obj.breadth);
A. 20
B. 12
C. undefined
D. error
 
Answer: b
Explanation: The “in” operator checks for the presence of a particular property in object. It returns true if the property is present and returns false if the property is not present.
 

Tìm kiếm

Back
Top