summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatthewsot <matthewsot@outlook.com>2017-06-17 00:19:21 -0700
committermatthewsot <matthewsot@outlook.com>2017-06-17 00:19:21 -0700
commit3939729035dbcb863e35cbb14460147cfb9cfa91 (patch)
tree92a0e8fb9d0822d923bef09bd58ea14d5850da37
parentc06dc7a46b2078819c4177d35c871b7e6af7e502 (diff)
slightly fixed up README
-rw-r--r--README.md14
1 files changed, 7 insertions, 7 deletions
diff --git a/README.md b/README.md
index c278d09..bf22807 100644
--- a/README.md
+++ b/README.md
@@ -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``
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback