var book = {
main title: JavaScript,
'sub-title': The Definitive Guide,
for: all audiences,
author: {
firstname: David,
surname: Flanagan
}
};
properties
property values
property names
objects
C. property names
High level programming language
Assembly level programming language
Machine level programming language
Low level programming language
prototype stack
prototype chain
prototype class
prototypes
debugger
with
if
use strict
Properties
Prototypes
Lvalue
Definition
the head tag
the head or body
the title or head
after the body tag
Alternative to if-else
Immediate if
If-then-else statement
Switch statement
!!(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
String
Object
Serialized Object
Array
function equalto()
{
int num=10;
if(num===10)
return true;
else
return false;
}
true
false
runtime error
compilation error
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
<script>
txt1 = “ one”;
txt1 += “two”;
document.getElementById("demo").innerHTML = txt1;
</script>
onetwo
one two
error
undefined
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
in
exist
within
exists
int a=1;
if(a!=null)
return 1;
else
return 0;
1
0
runtime error
compiler error
int a==2;
int b=4;
int ans=a+b;
print(ans);
2
6
0
error
false.toString()
String(false)
String newvariable=false
Both false.toString() and String(false)
var pow=new Function(num1,num2,return Math.pow(num1,num2));
document.writeln(pow(2,3));
2
3
8
error
void
int
function
main
var string1 = 123;
var intvalue = 123;
alert( string1 + intvalue );
123246
246
123123
Exception
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
function f() {};
Function f
A custom constructor
Prototype of a function
Not valid
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]);
Alternative to if-else
Immediate if
If-then-else statement
Switch statement
stand-alone expressions
basic expressions containing all necessary functions
contains variable references alone
contains only keywords
If the object inherits enumerable properties
The object does not have the properties present in the integer array indices
The delete keyword is never used
Object.defineProperty() is not used
Int a=1;
if(a>10)
{
document.write(10);
}
else
{
document.write(a);
}
10
0
1
Undefined
function range(int length)
{
int a=5;
for(int i=0;i<length;i++)
{
console.log(a);
}
}
range(3);
5
555
3
error
var o = new Object();
var o = Object();
var o;
var o= new Object;
Object o=new Object();
src
ext
script
link
var grade='A';
var result;
switch(grade)
{
case 'A':
result+=10;
case 'B':
result+= 9;
case 'C':
result+= 8;
default:
result+= 0;
}
document.write(result);
10
27
8
0