Keywords
Declaration statements
Data types
Prototypes
B. Declaration statements
function height()
{
var height = 123.56;
var type = (height>=190) ? tall : short;
return type;
}
123.56
190
tall
short
00
0x
0X
Both 0x and 0X
var values=[one,two,Three];
var ans=values.shift();
document.writeln(ans);
one
two
three
error
Primary Expression
Object Creation Expression
Invocation Expression
Constructor Calling Expression
const object1 = {
property1: 20
};
console.log(Object.is(object1));
20
true
false
error
An integer
A String
An object
Floating point
It is mandatory
Not necessary
Few functions return values by default
some functions do not return any value
RMI
Triggering Event
Preprocessor
Function/Method
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]
function compare()
{
int num=2;
char b=2;
if(a==b)
return true;
else
return false;
}
true
false
runtime error
compilation error
var tensquared = (function(x) {return x*x;}(10));
Yes, perfectly
Error
Exception will be thrown
Memory leak
<script>
txt1 = “ one”;
txt1 += “two”;
document.getElementById("demo").innerHTML = txt1;
</script>
onetwo
one two
error
undefined
maps the elements of another array into itself
passes each element of the array and returns the necessary mapped elements
passes each element of the array on which it is invoked to the function you specify, and returns an array containing the values returned by that function
pass the elements of the array into another array
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
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
Ignores the statement
Prompts to complete the statement
Throws an error
Shows a warning
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]);
Keywords
Declaration statements
Data types
Prototypes
var grade='E';
var result;
switch(grade)
{
case 'A':
result+=10;
case 'B':
result+= 9;
case 'C':
result+= 8;
default:
result+= 0;
}
document.write(result);
10
0
18
17
make all of the own properties of that object non configurable
to configure and bring a writable property
lock down objects into a known state and prevent outside tampering
to include new properties into the object
Returns the value and continues executing rest of the statements, if any
Returns the value and stops the program
Returns the value and stops executing the function
Stops executing the function and returns the value
function info()
{
int a=1;
int b=2;
return a*b;
}
document.write(info());
1
2
3
error
var string2Num=parseInt(123xyz);
123
123xyz
Exception
NaN
The interpreter stops its work
The interpreter throws another exception
The interpreter jumps to the nearest enclosing exception handler
The interpreter throws an error
const obj1 = { property1: '10'};
const obj2 = Object.freeze(obj1);
obj2.property1 = '20';
console.log(obj2.property1);
10
20
Runtime error
Compilation error
var text = testing: 1, 2, 3; // Sample text
var pattern = /d+/g // Matches all instances of one or more digits
text==pattern
text.equals(pattern)
text.test(pattern)
pattern.test(text)
Alternative to if-else
Immediate if
If-then-else statement
Switch statement
decrements the total length by 1
increments the total length by 1
prints the first element but no effect on the length
updates the element
var grade='B';
var result;
switch(grade)
{
case 'A':
{
result+=10;
break;
}
case 'B':
{
result+= 9;
break;
}
case 'C':
{
result+= 8;
break;
}
default:
result+= 0;
}
document.write(result);
10
9
8
0
Syntax error
Missing of semicolons
Division by zero
Missing of Bracket