Skip to content
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

New tip for jstips - Improve Nested Conditionals #3

Merged
merged 15 commits into from Jan 3, 2016

Conversation

AlbertoFuente
Copy link
Contributor

No description provided.

@padsbanger
Copy link

Using switch in Javascript is not a good pattern. https://toddmotto.com/deprecating-the-switch-statement-for-object-literals/

@AlbertoFuente
Copy link
Contributor Author

Thanks you for your point padsbanger, I know it's not appropriate to use switch on javascript and the problems associated with its use, I'm trying to convey the steps to improve nested if and nested if with several checks in each statement. Maybe I should add the problems associated with the use of switch.

@AlbertoFuente
Copy link
Contributor Author

In line with this, I remember that Eric Elliot retracted his advice about not using switch statements https://twitter.com/_ericelliott/status/673011325568610305

@loverajoel loverajoel self-assigned this Dec 30, 2015
@loverajoel
Copy link
Owner

@AlbertoFuente hey nice tip, it's true the switch is not a good pattern but you can explain it.
I like the tip, if you edit your tip I will merge this the January 3, please add your tip at the end of the Tip List and update the date.
Thanks for your help.

};

if (color) {
colorObj[color]();
Copy link
Contributor

Choose a reason for hiding this comment

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

It will be a good idea to check
colorObj.hasOwnProperty(color)
before we use.

@AlbertoFuente
Copy link
Contributor Author

@loverajoel Ok, I will improve it, and thank you for this great initiative. 👍
@manmadareddy Thank you for your contribution, I will add to the example. 👍

@ghost
Copy link

ghost commented Dec 31, 2015

switch(!!color) {
  case (typeof color != 'string'): break;
  case (color == 'blue'): console.log('Blue') break;
  case (color == 'green'): console.log('Green') break;
}

@kotAPI
Copy link

kotAPI commented Jan 1, 2016

we want more jstips!!! one jstip a day keps bugs away!

@AlbertoFuente
Copy link
Contributor Author

Thanks for improvement @noncentz.

@loverajoel
Copy link
Owner

@AlbertoFuente the contributions guidelines changed, and the new tips will be at the top of the list.
Please can you move your tip to the top and squash your commits?
Thanks

@AlbertoFuente
Copy link
Contributor Author

I've already put the tip above the others, I have a question, I see different types of numbering for tips:

0 - Insert ...

1 - angularjs ...

02 - ReactJs ...

It would be nice to specify a standard for numbering the tips.

@loverajoel
Copy link
Owner

@AlbertoFuente awesome! the tips numbering should be 00, 01, 02, 03... I made a mistake with the previous two and now I can't fix because the tweets are going to lost the link(works with the title).
Please add the 03 and don't forget squash your commits.
After that I'll merge the PR.

Thanks man

@AlbertoFuente
Copy link
Contributor Author

I'm having troubles with the squash

@loverajoel
Copy link
Owner

@AlbertoFuente this is a good article about squash commits.
Don't worry I can do the squash for you after merger the PR

@AlbertoFuente
Copy link
Contributor Author

Thank you very much, there's something I'm not doing well.

@loverajoel
Copy link
Owner

@AlbertoFuente don't worry, thanks for your tip!

loverajoel added a commit that referenced this pull request Jan 3, 2016
New tip for jstips - Improve Nested Conditionals
@loverajoel loverajoel merged commit 25e0977 into loverajoel:master Jan 3, 2016
fundon pushed a commit to fundon/jstips that referenced this pull request Jan 26, 2016
petetnt added a commit to petetnt/jstips that referenced this pull request Mar 5, 2016
zenopopovici added a commit that referenced this pull request Mar 5, 2016
Update Tip #3 Improve Nested Conditionals with a refactoring example
zenopopovici added a commit that referenced this pull request Aug 21, 2016
zenopopovici added a commit that referenced this pull request Apr 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants