Instead of using jQuery’s .toggleClass() method to add or remove classes from an element, I can use the Element.classList.toggle() method to achieve the similar goal. The method will return true if the value is successfully added to the element class, otherwise, it will return false.
It’s a perfectly valid choice for a fairly simple application.
Filter my list of cars
Filter my list of heroes
Filter my dirty clothes…
Filter my favorite shoes…
Filter my favorite foods…
Filter the candidate to be included in my crew…
I think there is a lot of things we can filter out of an Array. A lot of things…
Have not used Array.filter() before? If yes, then consult the complete reference at MDN.
It’s cool, isn’t it? Imagine if we can tap this tool into build process to keep the codebase as clean as possible. But, if you guys also curious enough about jsinspect like myself, try to use it in your daily workflow, see how the tool can help you find the duplicate code easily.
I like the idea of chaining the promises in my code so that it looks nice, pretty nice and easier to read. After several months following this pattern, I have a situation where I need to break the chain promise flow, like stopping the flow. See the below snippet code:
From the above code, I am expecting the code to stop chain and move on to the .catch handler, but is not. I learned the code will continue the flow as I return with no value at line 9.
So, here is the way to break the promise chains, instead of returning with no value, I throw an Error to stop the flow:
Oh, yeah I use Bluebird to working with Promise…
Last week I started working on a project to apply the Material Design into the AngularJS based application. I’m not quite sure how it goes since the application is already based on Bootstrap, and not quite sure which Boostrap themes I should use. Today, I kinda interested to use Polymer since it has a Paper elements, but not quite sure how Polymer can coexist in AngularJS application, so I google it using polymer in angularjs and found an interesting search result.
Angular Material! I’m started thinking like this is what I need. I think for now I will try Angular Material, and if its good then I will drop my intention to use Paper elements for now.