Giter Site home page Giter Site logo

howprogrammingworks / function Goto Github PK

View Code? Open in Web Editor NEW
41.0 22.0 175.0 119 KB

Functions as a method to raise level of code abstraction

Home Page: https://youtube.com/TimurShemsedinov

License: MIT License

JavaScript 100.00%
iife function closure functional-programming abstraction programming university code learning study

function's Issues

Improvement suggestions for d-decompose.js

  • change introspect function so that it can handle objects included
  • change introspect function so that it can handle recursive objects
  • parseLines improvement so that it can process more than one space b/w parameter name and data type
  • add support for curried functions multiline structure
    e.g.
'use strict';

const currdObj = { 
	common: {
			sum:  (
			// Partial sum apply, use first argument
			x // first argument which should support summation opertaion
			// Example: sum(1)
			// Returns: function(y) { return 1 + y }
		) => (
			// Apply curreied sum to second argument
			y // second argument which should support summation operation
			// Example: sum(1)(2)
			// Returns: 3
		) => (
			x + y
		) 
	}
};

introspect(currdObj)

Extend test cases with passing a named function

According to MDN (source):

If function name is omitted, it will be the variable name (implicit name).
If function name is present, it will be the function name (explicit name).

Code exmaple:

const foo = function () {};
foo.name // "foo"

const foo2 = foo;
foo2.name // "foo"

const bar = function baz() {};
bar.name // "baz"

I suggest extending test cases with the following case:

diff --git a/Exercises/4-methods.test b/Exercises/4-methods.test
index a408b22..78eb07d 100644
--- a/Exercises/4-methods.test
+++ b/Exercises/4-methods.test
@@ -10,11 +10,15 @@
         },
         m3(x, y, z) {
           return [x, y, z];
-        }
+        },
+        m4: function sum(x, y) {
+          return x + y;
+        },
       }, [
         ['m1', 1],
         ['m2', 2],
-        ['m3', 3]
+        ['m3', 3],
+        ['sum', 2],
       ]
     ],
   ]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.