The typeof javaScript operator and other data type related things

The javaScript typeof operator will return a string that is the type of the operand that is given to it from the right of the typeof keyword when used in an expression. It is the first go to operator then to go about preforming type checking of values in javaScript.

However when it comes to data type checking in javaScript there are also some additional things to look out for when it comes to really knowing what one is dealing with when it comes to values. For example when it comes to objects the typeof operator will always return object, but will not give insight into the type of object. So the typeof operator is not a replacement for other keywords such as the instance of operator that will help to know what kind of object a value is when it is in fact an object.

The typeof operator might not always give the desired results in many cases. Maybe the most note worthy issue to be aware of is that it will return the value ‘object’ when used with a null value. This is actually the value that it should return, but some developers might considered this a bit confusion, and in any case it is something that one has to adjust for no matter what anyway.

Read More

lodash main post from why bother to getting started and beyond.

When it comes to javaScript utility libraries Lodash is such a library that provides over three hundred modular utility functions to help work with arrays, functions, and objects in general. On top of having just array methods and plain object methods there are a number of collection methods that will work with arrays and objects in general. There are also many methods that will work well with primitive values as well such as Strings and Numbers. There are also a lot of other useful various utility methods that one would expect to find in a library such as this.

Many of the methods in lodash are in line with the concepts of functional programming such as conforming to rules that are constant with the concept of a pure function. That is a function in which the same result is returned for the same set of arguments that are given when the function is called.

It is true that many of the functions in lodash are from underscore the older library from which lodash was forked. At first it was stated that lodash would work as a drop in replacement for underscore, but with late versions of lodash that is no longer the case as there are many differences when it comes to the public APIS of these two projects.

One major talking point as to why developers should not bother with lodash any more is that much of the functionality in lodash is now part of core native javaScript itself. However there is still some people out there using older browsers that do not support all of these native methods, and I also like to get my code to work on a wide range of versions numbers when it comes to making nodejs scripts. There is also a lot to talk about when it comes to other reasons why using lodash still makes sense beyond just that of the safety net aspect of the library. I mentioned that many of the methods are more in line with functional programing, and that many of the methods are collection methods that will work out of the box with a wider range of objects beyond just that of arrays. In addition many of the utility methods are still not part of core javaScript at all, so it is not necessarily a dead library, and there is still a desire to abstract and wrap away many native methods and have something that conforms to the ides of a pony fill rather than a poly fill.

Read More

lodash array methods collection methods and more

The lodash array methods are methods that can be used to preform common tasks with arrays rather than objects in general when it comes to the many collection method that there are to work with. Many of these methods are baked into core javaScript itself these days, however many are not as well, or the lodash methods have a few more features that set it apart from the native counterpart. In some cases the lodash counter part of an array method is not an array method, but a collection method such is the case with the lodash for each method compared to the native array for each method.

So in this post I will be going over some of the lodash array methods that stand out for me. These methods are useful in some cases, also some of them have no native counterpart and can often prove to be a little time consuming time cerate or fine a copy and past vanilla javaScript solution for.

Read More

The javaScript Date Constructor.

The javaScript Date constructor can be used to create Date objects that represent a single moment, or time stamp at a point in the past, the current time, or the future. So then the Date constructor is the first go to method for working with time in a javaScript programing environment.

The Date object is an example of a constructor function meaning that it is a function that can be used to create a class of an object that has prototype object methods that can be called off of an instance of the Class object. When it comes to date objects as one would expect there are a whole bunch of methods that have to do with getting the number of seconds, minutes, and hours many many other such values from such a class object.

In javaScript date objects use Unix time, A system of time based on a number of seconds passed a fixed point in the past. In this post I will be covering some of the basics of javaScript Dates as well as maybe some more advanced related topics as well centered around time.

Read More

lodash object methods and beyond

In lodash methods there are a number of Object methods on top of array methods, and collection methods. When it comes to array method these kinds of method will just work with an array that is given as the source object, while collection methods will work with any kind of collection not just arrays. Although it might be true that collection methods are also a kind of object method there are still methods that are designed to work with an object that is a collection of items.

When working with a collection in one form or another I would want to loop over the own properties of a collection object only. So then maybe a good way of knowing the difference between collection methods would be to take into account the nature of the lodash forEach collection method, and compare that to the lodash forIn object method. The forEach method will just loop over the public own properties of an object, while the forIn method will loop over all the own properties, and also the prototype object of the object as well.

In this post I hope to give a general overview of lodash object methods, and also of objects in general when it comes to just working with native javaScript alone while I am at it. This might just be what is called for in order to have a solid understanding as to what the difference is between collections and object methods in general.

Read More