What will be the output of the following JavaScript code? [code] function output(object) { var place=object ? object.place : “Italy”; return

Hằng Đoàn

New member
What will be the output of the following JavaScript code?
Code:
function output(object)
{
	var place=object ? object.place : “Italy”;
	return “clean:”+ place;
}
console.log(output({place:India}));
A. clean:India
B. clean:Italy
C. error
D. undefined
 
Answer: a
Explanation: ”?” operator is used to compare the values and place is initialized according to the true condition that whether it is true or false. The function is called in the console.log and the object value is passed.
 

Tìm kiếm

Back
Top