Skip to content

Instantly share code, notes, and snippets.

View stevez's full-sized avatar

Steve Zhang stevez

  • Markham, Ontario, Canada
View GitHub Profile
var F = function() {}; // This is a function object.
var p = F.prototype; // This is the prototype object associated with it.
var c = p.constructor; // This is the function associated with the prototype.
var c === F; // => true: F.prototype.constructor==F for any function
function foo() {
alert("foo");
}
var foo = function() {
alert("foo");
};
var foo = function() {
alert("foo");
};
//call before function foo is defined
foo(); //=> alert("foo");
function foo() {
alert("foo");
}
//call after function foo is defined
foo(); //=> alert("foo");
//call before function foo is defined
foo(); // will fail, because foo() is not defined.
var foo = function () {
alert("foo");
}
//call after function foo is defined
foo(); //=> alert("foo");
var myObject = {
value: 0,
increment: function() {
this.value +=1;
return this.value;
}
}
myObject.increment(); // => 1
var myObject = {
value: 0,
increment: function() {
value +=1;
return value;
}
}
myObject.increment(); // => ERROR
var myObject = {
value: 0,
increment: function() {
value +=1;
return value;
}
}
myObject.increment(); // => ERROR
// Get acceleration
PhoneGap.exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);