Skip to content

Conversation

@VKNS
Copy link

@VKNS VKNS commented Jul 16, 2019

No description provided.

Copy link

@svvald svvald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good work in general with a couple of recommendations given

@@ -0,0 +1,26 @@
Function.prototype.myBind = function(context) {
if (typeof this !== 'function') {
Copy link

@svvald svvald Aug 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that you don't need this check since you are changing the prototype of Function. If you will try to invoke myBind from string, for instance, you'll get TypeError: myBind is not a function

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -0,0 +1,14 @@
function countDown(num) {
for (var i = num; i >= 0; i--) {
function time(i) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move function declaration outside of for loop

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

}, 1000 * (num - i));
}
var binded = time.bind(null, i);
binded(i);
Copy link

@svvald svvald Aug 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could write it like this time.bind(null, i)() or even better time.bind(null)(i) which is called currying.
Although I don't insist on changing it but strongly recommend you to read more about it since it is a part of functional approach and some JS programmers prefer it to imperative nowadays

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants