This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var obj1 = { | |
num : 4 | |
} | |
function multiply(val){ | |
return this.num * val; | |
} | |
console.log(multiply(3)); //impossible because no num defined in window (NaN) | |
console.log(multiply.apply(obj1, [4])); //16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<button id='thebutton'>Click me!</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.statusId = 1; | |
var module = { | |
statusId : 4, | |
getStatus : function(){ | |
return this.statusId; | |
} | |
}; | |
console.log(module.getStatus()); //4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var first_object = { | |
num: 4 | |
}; | |
function multi(mul) { | |
return this.num * mul; | |
} | |
Function.prototype.bind = function (obj) { | |
var method = this, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var first_object = { | |
a: 2, | |
b: 4 | |
}; | |
function adder(val1, val2) { | |
return this.a + this.b + val1 + val2; | |
} | |
Function.prototype.bind = function (obj) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log("Before " + value1); //Before undefined | |
var value1 = "This is value1"; | |
console.log("After " + value1); //After This is value1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var var1 = 1; | |
var var2 = 2; | |
(function () { | |
console.log("var1 = " + var1); | |
var var1 = 10; | |
console.log("var2 = " + var2); | |
console.log("var1 =" + var1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class X | |
{ | |
protected virtual void F() { Console.WriteLine("X.F"); } | |
protected virtual void F2() { Console.WriteLine("X.F2"); } | |
} | |
class Y : X | |
{ | |
sealed protected override void F() { Console.WriteLine("Y.F"); } | |
protected override void F2() { Console.WriteLine("Y.F2"); } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isAsync = true; | |
function callWebService(){ | |
console.log('Calling web service'); | |
$.ajax({ | |
url: "http://date.jsontest.com/", | |
async : isAsync | |
}).done(function (data) { | |
console.log(data); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.when($.ajax('http://date.jsontest.com')) | |
.then(function(data){ | |
//Will be executed if the ajax is successful | |
console.log('data ' + data); | |
}). | |
fail(function(data){ | |
//Will be executed if the ajax gets fails | |
console.log('Fail'); | |
}); |
OlderNewer