function printprops(o)
{
for(var p in o)
console.log(p + : + o[p] +
);
}
Prints the contents of each property of o
Returns undefined
Prints only one property
Prints the address of elements
B. Returns undefined
function tail(o)
{
for (; o.next; o = o.next) ;
return o;
}
No, this will throw an exception as only numerics can be used in a for loop
No, this will not iterate
Yes, this will work
No, this will result in a runtime error with the message Cannot use Linked List
string a = hi;
string b =there;
alert(a+b);
hi
there
hithere
undefined
var values=[one,two,Three];
var ans=values.shift();
document.writeln(ans);
one
two
three
error
void
int
function
main
The property will be stored in a cache
The loop will not run
That property will not be enumerated
The property will be enumerated
for(var num=10;num>=1;num--)
{
document.writeln(num);
}
var num=10;
while(num>=1)
{
document.writeln(num);
num++;
}
Code 1
Code 2
Both Code 1 and Code 2
Cannot Compare
int a=0;
for(a;a<5;a++);
console.log(a);
0
error
4
5
debugger
with
if
use strict
!!(obj1 && obj2);
(obj1 && obj2);
Both the lines result in a boolean value True
Both the lines result in a boolean value False
Both the lines checks just for the existence of the object alone
The first line results in a real boolean value whereas the second line merely checks for the existence of the objects
if(a!=null)
if (!a)
if(a!null)
if(a!==null)
Alternative to if-else
Immediate if
If-then-else statement
Switch statement
for(var p in o)
console.log(o[p]);
for (var i = 0;i < a.length;i++)
console.log(a[i]);
for (int i = 0;i < a.length;i++)
console.log(a[i]);
for (var i = 0;i <= a.length;i++)
console.log(a[i]);
for (var i = 1;i < a.length;i++)
console.log(a[i]);
Ignores the statement
Prompts to complete the statement
Throws an error
Shows a warning
var arr=[1,2,3];
var rev=arr.reverse();
document.writeln(rev);
1, 2, 3
3, 2, 1
3
1
const object1 = {};
a = Symbol('a');
b = Symbol.for('b');
object1[a] = 'harry';
object1[b] = 'derry';
const objectSymbols = Object.getOwnPropertySymbols(object1);
console.log(objectSymbols.length);
0
2
1
Error
while (a != 0)
{
if (a == 1)
continue;
else
a++;
}
The continue keyword restarts the loop
The continue keyword skips the next iteration
The continue keyword skips the rest of the statements in that iteration
The continue keyword breaks out of the loop
o.m=m.f;
o.m=f;
o=f.m;
o=f;
int a=4;
int b=1;
int c=0;
If(a==b)
document.write(a);
else if(a==c)
document.write(a);
else
document.write(c);
4
1
Error
0
const obj1 = { property1: '10'};
const obj2 = Object.freeze(obj1);
obj2.property1 = '20';
console.log(obj2.property1);
10
20
Runtime error
Compilation error
Primary Expression
Object Creation Expression
Invocation Expression
Constructor Calling Expression
conditional block
block that contains a single statement
both conditional block and a single statement
block that combines multiple statements into a single compound statement
make computations in HTML simpler
minimize storage requirements on the web server
increase the download time for the client
increase the loading time of the website
var string1 = 123;
var intvalue = 123;
alert( string1 + intvalue );
123246
246
123123
Exception
An integer
A String
An object
Floating point
It returns the value 0
It will throw an exception
It returns the undefined value
It will throw an error
Floating numbers
Representation of functions that returns a value
is not present in JavaScript
Form feed
continue statement
break statement
goto statement
return statement
function info()
{
int a=1;
int b=2;
return a*b;
}
document.write(info());
1
2
3
error
var a = [1,2,3,4,5];
a.slice(0,3);
Returns [1,2,3]
Returns [4,5]
Returns [1,2,3,4]
Returns [1,2,3,4,5]
will throw errors and exceptions
must be restricted to a Unix Machine only
will work perfectly well on a Windows Machine
will be displayed as a JavaScript text on the browser