diff options
author | matthewsot <matthewsot@outlook.com> | 2017-06-17 00:19:21 -0700 |
---|---|---|
committer | matthewsot <matthewsot@outlook.com> | 2017-06-17 00:19:21 -0700 |
commit | 3939729035dbcb863e35cbb14460147cfb9cfa91 (patch) | |
tree | 92a0e8fb9d0822d923bef09bd58ea14d5850da37 | |
parent | c06dc7a46b2078819c4177d35c871b7e6af7e502 (diff) |
slightly fixed up README
-rw-r--r-- | README.md | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -1,19 +1,19 @@ # jfn -Playing around with Javascript functions +Playing around with Javascript functions. A global overloadable function: ``` jfn.defineFunction("testFunction", ["string"], function (str) { - alert("String: " + str); + return "String: " + str; }); jfn.defineFunction("testFunction", ["number"], function (num) { - alert("Num: " + num); + return "Num: " + num; }); jfn.defineFunction("testFunction", "*", function (data) { - alert("Catchall: " + JSON.stringify(data)); + return "Catchall: " + JSON.stringify(data); }); testFunction("Hello!"); //String: Hello! @@ -29,8 +29,8 @@ jfn.defineFunction(Math, "root", ["number", "number"], [2], function (base, powe return Math.pow(base, (1 / power)); }); -alert(Math.root(8, 3)); //2 (cubed root of 8) -alert(Math.root(9)); //3 (square root of 9) +Math.root(8, 3); //2 (cubed root of 8) +Math.root(9); //3 (square root of 9) ``` jfn.defineFunction arguments: @@ -38,7 +38,7 @@ jfn.defineFunction arguments: jfn.defineFunction(object, propertyName, argumentTypes, defaults, function); ``` -``object`` is the object you'd like to define the function on +``object`` is the object you'd like to define the function on (leave it out to define on the global ``window`` object) ``propertyName`` is the name of the function that you'd like to define on ``object`` |