From 4e5ef568f4b1c3a58e7d63b10b32a627f4e1e977 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 8 May 2020 14:42:21 +0300 Subject: [PATCH] docs... Signed-off-by: Alex A. Naanou --- README.md | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index fe67db4..5b52712 100755 --- a/README.md +++ b/README.md @@ -227,13 +227,7 @@ var Action = object.Constructor('Action', return this }) -var action = new Action() - -// the instance now is a function... -action() - - -// a different way to do the above... +// a more flexible approach... // // This is the same as the above but a bit more convenient as we do // not need to use Object.assign(..) or object.mixinFlat(..) to define @@ -245,6 +239,13 @@ var Action2 = object.Constructor('Action2', { }, }) + +var action = Action() +var action2 = new Action2() + +// the instances are now functions... +action() +action2() ``` In the above cases both the _function constructor_ and the `.__call__(..)` @@ -262,9 +263,14 @@ user's responsibility to call `.__call__(..)` method. **Notes:** - the two approaches (_function_ vs. `.__call__(..)`) will produce - slightly different results, the difference is in `.prototype`, in the - first case it is a _function_ while in the second an object with a - `.__call__(..)` method. + functionally identical but structurally different constructors/objects, + the difference is in `.prototype`: + + - _prototype function_ -> `.prototype` is a function object + - `.__call__(..)` -> `.prototype` object with a `.__call__(..)` method + + The instance in both cases is a function wrapper that will proxy the + call to the corresponding implementation. (this may change in the future)