In this section I will be going over some quick simple examples using _.size that should help show why it might be a useful collection method. The use of _.size is fairly easy, just pass it an Array or object and it will give the element length or the number of keys. There are some pit falls to be aware of when using _.size, or when just working with Arrays and objects in general actually so I will be touching base on that as well here. If you are more interested in vanilla js solutions I will be covering that in the next section.
When an array is passed to _.size the element length of that array is returned.
If a plain object without a length property is given to _.size the enumerable key length of that object is returned.
2.3 - Object.getOwnPropertyNames(obj).length for getting the key length of both enumerable and non-enumerable object own properties
So then in this section I will be going over some ways to get the data size of a string, in both nodejs and well as client side environments.
In nodejs the Buffer Class is there to work with when it comes to these kinds of situations. There are a number of was to create an instance of a buffer, for this example I went with the from method of the buffer class.