var string1 = ”123”; var intvalue = 123; alert( string1 + intvalue );
Answer: 123123
var string1 = ”123”; var intvalue = 123; alert( string1 + intvalue );
Answer: 123123
Answer: Function literal
Answer: stand-alone expressions
Consider the following JavaScript statements.
var text = "testing: 1, 2, 3"; // Sample text
var pattern = /\d+/g // Matches all instances of one or more digits
In order to check if the pattern matches with the string “text”, the statement is ____________
Answer: pattern.test(text)
Answer: Invocation expression
Answer: Object Creation Expression
Answer: in
Answer: Lvalue
x = ~-y; w = x = y = z; q = a?b:c?d:e?f:g;
Answer:x = ~(-y); w = (x = (y = z)); q = a?b:(c?d:(e?f:g));
function output(option)
{
return (option ? “yes” : “no”);
}
bool ans=true;
console.log(output(ans));
Answer: Yes
var obj=
{
length:20,
height:35,
}
if (‘breadth' in obj === false)
{
obj.breadth = 12;
}
console.log(obj.breadth);
Answer: 12
function height()
{
var height = 123.56;
var type = (height>=190) ? "tall" : "short";
return type;
}
Answer: short
string a = ”hi”; string b =”there”; alert(a+b);
Answer: hithere
function output(object)
{
var place=object ? object.place : “Italy”;
return “clean:”+ place;
}
console.log(output({place:India}));
Answer: clean:India