























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
























'10' == 10 → true or false? alert( '10' + 10 ) →? alert( '10' * 10 ) →? alert( '10' * '10' ) →? Operations may not be type-safe i.e. type rules not enforced properly Implicit type conversion Type rules aren't uniform - unpredictable behavior
var a=1; alert(a); // output 1 function scopeTest(){ var a=2; alert(a); } scopeTest(); // output 2 alert(a); // output 1 var a=1; alert(a); // output 1 function scopeTest(){ a=2; alert(a); } scopeTest(); // output 2 alert(a); // output 2
(^) e.g. 123 printed as 321
(^) e.g. 5! = 120
var item = { title : "HTML Specification", status : "available", isAvailable : function (){ return this.status == "available"; } } alert(item.title); // HTML Specification alert(item.isAvailable()); // true
var item = new Object(); item.title = "HTML Specification"; item.status = "available"; item.isAvailable = function (){ return this.status == "available"; } alert(item.title); // HTML Specification alert(item.isAvailable()); // true
var obj = new Item("HTML Specification"); var output = ''; for(x in obj){ output += x + ": " + obj[x] + ";" ; } alert(output);
var item1 = new Item("HTML Specification"); alert(item1.title); // HTML Specification alert(item1.isAvailable()); // true item1.issue = function(){ this.status = "issued"; } alert( item1.isAvailable() ); // true item1.issue(); alert( item1.isAvailable() ); // false var item2 = new Item("Javascript Specification"); alert(item2.title); // Javascript Specification alert(item2.isAvailable()); // true alert( item2.isAvailable() ); // true item2.issue(); // Exception alert( item2.isAvailable() ); // true