Today number

Returning the number of the day in the year

The day that I was writing this article was 12th of January, so it does return 12.

Fifty Fifty

Returning randomly true or false with the same 50% of probability

Dynamic call

Calling dynamically a function inside an array

Getting form

It’s quite easy to get the data from our form inputs

Serializing data

JSON data

UUID

Generate a unique universal identifier

Device type

You can improve your website responsivity by detecting the device of the user

Capitalize

Capitalizing the first letter from string

Decapitalize

As well as we can capitalize letters, we can revert it like this

Digitize

Converts a number into an array of digits.

Escape HTML

Sometimes we want to store HTML content into a database but to achieve this it’s vital to escape the HTML tags.

Unescape HTML

Well, if we want to get some day again the escaped tags it would be necessary to unescape them, isn’t it?

Strip HTML

Instead of still using the HTML strings maybe you only want the content inside so lets get rid the tags

Cleaning string

Remove the non ASCII characters from strings

Native type

Returns the native type of any value in JavaScript

Currency

Formatting numbers as money quantities is more easy than you think

Isn’t perfect but is a great approach to get formatted our currencies.

Remove with logic

With this snippet we are improving directly the Array prototype by adding a new method called “Remove”, even when I’ve already talked about removing keys from arrays in this story, this is better because in this way we can remove keys that match with the function that we pass as parameter.

JavaScript Tricks in real life

As almost all my stories, you can see alive all this snippets in this Codepen

https://codepen.io/adrian-legaspi/pen/rNavRLx

Conclusion

The only limitation when we are creating is ourselves. Give a try to this snippets and why not?, create new ones and share them. The more knowledge you share, the more that all of us will growth together, keep coding nice.