Schemetastic
Freebies
Soon
Posts about Front-end and +
As I promised in the past article (Click here if you
want to read it), I’ll explain how you can use TypeLib
JS to verify groups of data. But before, if you haven’t
seen it… Project page: typelib.schemetastic.com As we
learned in the past article, TypeLib makes data
verification easy, for example, you can verify values
such as NaN, Infinity and -Infinity. e.g. type(0/0).is;
// "nan" type(1000/0).is; // "infinity"
type(-1000/0).
If you want to see it in action, check out the project
landing page at: typelib.schemetastic.com Why I created
this project? 🔗Verifying data types in JS is hard! And
it can easily break code!!! 🫳🎤 … 🤏🎤 Okay, let
explain in more detail. JavaScript can handle dozens of
types of data (most of them are some sort of object),
but each type behaves differently, for example, a
"string" doesn’t behave in the same way as a new
String("does").
A brief intro 🔗When we think about technical writing
such as documenting code, or writing articles, we can
see some very obvious benefits, like: The code is easier
to understand to others but also to you. You help others
to learn. It can improve your CV. And you could even
commercially profit from it. And yes, I knew this stuff
before I started. However, some time ago I decided that
I was going to write articles specially about
JavaScript, a language I like, so like 8 weeks ago I
started writing articles in the DEV Community and I did
it without knowing all the benefits I would get from it.
In the previous part of this series I talked about how
you can shorten your conditionals with truthy and falsy
values. So if you haven’t read that one I would
recommend that you do cause this is a continuation, Link
here! In the past article I mentioned about string
interpolation and how does the ternary operator becomes
handy in these cases, however I knew that there was a
lot more to say about it.