Search This Blog

Friday, August 9, 2019

Find My Facebook ID

Some people ask me: How to get my Facebook ID such as: profile, group ,page.
I just find tool to answer this question, everyone can find here: Find My Facebook ID


Monday, July 21, 2014

XDomainRequest - Restrictions, Limitations and Workarounds

http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx

Friday, September 27, 2013

Javscript: the different between apply and call.

apply lets you invoke the function with arguments as an array; callrequires the parameters be listed explicitly.


Pseudo syntax:
theFunction.apply(valueForThis, arrayOfArgs)
theFunction.call(valueForThis, arg1, arg2, ...)
Sample code:
function theFunction(name, profession) {
    alert("My name is " + name + " and I am a " + profession + ".");
}
theFunction("John", "fireman");
theFunction.apply(undefined, ["Susan", "school teacher"]);
theFunction.call(undefined, "Claude", "mathematician");
Source: http://stackoverflow.com/questions/1986896/what-is-the-difference-between-call-and-apply

Thursday, November 8, 2012

Call function in string javascript

1. Using eval
 var strFun1 = "func1";
 var ret1 = eval(strFun1);
 ret1(1,2,3);
 function func1(a,b,c){
   alert(a);
   alert(b);
   alert(c);
}
1. Using Window property (Recommend)
 var strFun2 = "func2";
 window[strFun2](parmas);
 function func2(data){
   console.info(data);
 }


Friday, November 2, 2012

Difference between function and method in javascript

Every function in JavaScript has a number of attached methods, including toString()call(), and apply() (remember that every function in JavaScript is an object).
Functions stand on their own (there is an alert() function, for example), while methods are functions inside an object's dictionary, and we invoke them through the object reference

Example:
function foo()
{
    alert(
'x');
}
alert(foo.toString());


------------------------

fn.call and fn.apply


fn.call(function, [thisObject, [argument1, ..., argumentN]]) is equivalent to function.call(thisObject, argument1, ..., argumentN)
fn.apply(function, [thisObject, [argumentsArray]]) is equivalent to function.apply(thisObject, argumentsArray)

Examples:
function foo(a, b) { return (this*a)-b }
fn.call(foo, 5, 6, 7) == 23
foo.call(5, 6, 7) == 23
fn.apply(foo, 5, [6, 7]) == 23
foo.apply(5, [6, 7]) == 23
  1. if (typeof fn == "undefined" ) var fn = {};
  2. fn.call = function call(fn /*, [thisp, [arg1, ..., argN]]*/) { return Function.prototype.call.apply(fn, Array.prototype.slice.call(arguments).splice(1, arguments.length)) };
  3. fn.apply = function apply(fn, thisp, args) {
  4. if ( args ) args.splice(0, 0, thisp);
  5. return Function.prototype.call.apply(fn, args)
  6. };