var a= 0;
var b = 0;
while (a < 3)
{
a++;
b += a;
console.log(b);
}
135
123
013
01
A. 135
function equalto()
{
int num=10;
if(num===10)
return true;
else
return false;
}
true
false
runtime error
compilation error
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
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)
var tensquared = (function(x) {return x*x;}(10));
Yes, perfectly
Error
Exception will be thrown
Memory leak
var book = {
main title: JavaScript,
'sub-title': The Definitive Guide,
for: all audiences,
author: {
firstname: David,
surname: Flanagan
}
};
properties
property values
property names
objects
<script>
document.getElementById("demo").innerHTML = typeof "John"
</script>
integer
number
string
error
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
debugger
with
if
use strict
Identifier and Parentheses
Return type and Identifier
Return type, Function keyword, Identifier and Parentheses
Identifier and Return type
var obj=
{
length:20,
height:35,
}
if (breadth' in obj === false)
{
obj.breadth = 12;
}
console.log(obj.breadth);
20
12
undefined
error
function printArray(a)
{
var len = a.length, i = 0;
if (len == 0)
console.log(Empty Array);
else
{
do
{
console.log(a[i]);
} while (++i < len);
}
}
Prints the numbers in the array in order
Prints the numbers in the array in the reverse order
Prints 0 to the length of the array
Prints Empty Array
in
exist
within
exists
function info()
{
int a=1;
int b=2;
return a*b;
}
document.write(info());
1
2
3
error
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
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
[digits][.digits][(E|e)[(+|-)]digits]
[digits][+digits][(E|e)[(+|-)]digits]
[digits][(E|e)[(+|-)]digits]
[.digits][digits][(E|e)[(+|-)]digits]
var string1 = 123;
var intvalue = 123;
alert( string1 + intvalue );
123246
246
123123
Exception
directly into JS file and included into HTML
directly on the server page
directly into HTML pages
directly into the css file
var person =
{
name: Rahul,
getName: function()
{
nreturn this.name;
}
}
var unboundName = person.getName;
var boundName = unboundName.bind(person);
document.writeln(boundName());
runtime error;
compilation error
Rahul
undefined
RMI
Triggering Event
Preprocessor
Function/Method
Procedures
Method
Static function
Dynamic function
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
Volatile variable
Mutable variable
Immutable variable
Dynamic variable
Updation, Incrementation, Initialization
Initialization,Testing, Updation
Testing, Updation, Testing
Initialization,Testing, Incrementation
function range(int length)
{
int a=5;
for(int i=0;i<length;i++)
{
console.log(a);
}
}
range(3);
5
555
3
error
switch(expression)
{
statements
}
==
equals
equal
===
stand-alone expressions
basic expressions containing all necessary functions
contains variable references alone
contains only keywords
String
Object
Serialized Object
Array
debugger
with
if
use strict
parse
a sync
defer
type