-
Notifications
You must be signed in to change notification settings - Fork 12
Nikita Korzhavin js-1 #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
svvald
left a comment
There was a problem hiding this 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
Nikita_Korzhavin/js10myBind.js
Outdated
| @@ -0,0 +1,26 @@ | |||
| Function.prototype.myBind = function(context) { | |||
| if (typeof this !== 'function') { | |||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Nikita_Korzhavin/js9countDown.js
Outdated
| @@ -0,0 +1,14 @@ | |||
| function countDown(num) { | |||
| for (var i = num; i >= 0; i--) { | |||
| function time(i) { | |||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Nikita_Korzhavin/js9countDown.js
Outdated
| }, 1000 * (num - i)); | ||
| } | ||
| var binded = time.bind(null, i); | ||
| binded(i); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
No description provided.