High level programming language
Assembly level programming language
Machine level programming language
Low level programming language
A. High level programming language
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=1;
if(a>10)
{
document.write(10);
}
else
{
document.write(a);
}
10
0
1
Undefined
[digits][.digits][(E|e)[(+|-)]digits]
[digits][+digits][(E|e)[(+|-)]digits]
[digits][(E|e)[(+|-)]digits]
[.digits][digits][(E|e)[(+|-)]digits]
var count = [1,,3];
The omitted value takes undefined
This results in an error
This results in an exception
The omitted value takes an integer value
var count = 0;
while (count < 10)
{
console.log(count);
count++;
}
The values of count are logged or stored in a particular location or storage
The value of count from 0 to 9 is displayed in the console
An error is displayed
An exception is thrown
function code(id,name)
{
this.id = id;
this.name = name;
}
function pcode(id,name)
{
code.call(this,id,name);
}
document.writeln(new pcode(101,vivek).id);
vivek
101
Runtime error
Compilation error
<script>
document.getElementById("demo").innerHTML = typeof "John"
</script>
integer
number
string
error
if(a!=null)
if (!a)
if(a!null)
if(a!==null)
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
directly into JS file and included into HTML
directly on the server page
directly into HTML pages
directly into the css file
int sum=0;
var arr = [10,15,20,30];
arr.forEach(function myFunction(element)
{
sum= sum+element;
});
document.writeln(sum);
70
75
10
error
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
var string1 = 123;
var intvalue = 123;
alert( string1 + intvalue );
123246
246
123123
Exception
<script>
var x = 10;
x *= 5;
document.getElementById("demo").innerHTML = x;
</script>
5
10
50
Error
The interpreter stops its work
The interpreter throws another exception
The interpreter jumps to the nearest enclosing exception handler
The interpreter throws an error
debugger
with
if
use strict
Ignores the statement
Prompts to complete the statement
Throws an error
Shows a warning
7.25
-7.25
7
-7
var txt1 = good;
var txt2 = day;
document.getElementById(demo).innerHTML = txt1 + txt2;
good day
goodday
error
undefined
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
var arr = [7, 5, 9, 1];
var value = Math.max.apply(null, arr);
document.writeln(value);
7
5
1
9
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 output(option)
{
return (option ? yes : no);
}
bool ans=true;
console.log(output(ans));
Yes
No
Runtime error
Compilation error
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
Both a and b are equal in value, type and reference address
Both a and b are equal in value
Both a and b are equal in value and type
There is no such statement
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
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)
const obj = {prop: 12};
Object.preventExtensions(obj);
console.log( Object.isExtensible(obj));
12
false
true
error
var obj=
{
length:20,
height:35,
}
if (breadth' in obj === false)
{
obj.breadth = 12;
}
console.log(obj.breadth);
20
12
undefined
error
Keywords
Declaration statements
Data types
Prototypes