lodash has method

This will be a quick post on the lodash has method, a simple object method that can be used to check if an object has a certain path in it or not. That is you pass a string that contains property names separated with dots to a certain value that is in the object. In the event that it is there then the lodash has returns true otherwise it will return false. So it is just a way to go about testing for a property of an object by way of a string value rather than an actual javaScript property syntax.

This is one of many methods in lodash that accept a string form of a object path to a value. Another such method of note in lodash would be the _.get, and _.set methods. This is not one of the most compelling methods in lodash, in fact when it comes down to it there are only really a handful that I find myself still using in projects. Still when it comes to gaining a comprehensive understanding of everything available within lodash it makes sense to not just write about the popular, or often used methods. Also maybe there are some situations in which it is nice to test for a object property by way of a string.

Read More

vue mixin and creating gloabl and local custom Vue options

There sure is a lot to cover to get up and running with vuejs to get into a space where a developer can start making some interesting and useful projects. In this post I will be writing about what a vue mixin is, which is one of many little things that one should have a solid grasp on before diving making a complex vuejs project.

A mixin is a way to create functionality that can be used across two or more components. If you do not have at least some background on vuejs components it might be a good idea to read up more on them to while you are at it. Anyway a mixin object can be passed to a mixins options when creating a component, or it can also be made global for all components and vuejs instances in general by using the Vue.mixin static method.

Read More

The lodash keys method and native javaScript

The lodash keys method in lodash can be used to get an array of public key names of an object. There is also the native Object.keys method as well that has been introduced in recent years. In addition a for in loop is another option for getting object keys that has great backward compatibility with older environments, so this makes the lodash _.keys method one of many methods in lodash that make me scratch my head wondering if I should bother or not.

Read More

vue directive basics and beyond

If you start getting into vuejs the concept of a vue directive is something that will come up, and it is important to understand what they are. There might be a range of ways of defining what a directive is, but maybe a good way of summing things up is that they are just a way to go about preforming some kind of an action on an html element in a static vue template. Actions such as changing what the text node is for a paragraph element, assigning a value for a style attribute of an element, or attaching an event handler for a button element.

There are many built in directives and an important part of vuejs development involves knowing how to use them first and foremost before looking into taking the time to make a custom directive. However speaking of custom directives, yes in addition to knowing about the built in ones it also goes without saying that it is a good idea to also know how to make them also. Directives are a great way to add features that act on elements that are needed for a project, but are not built into vuejs itself.

If you have some background with angular chances are you will be able to get up and running with vue directives fairly fast. However in any case in this post I will be getting into some simple, and maybe not so simple vue directive examples. Starting out with some very basic hello world type examples, and then getting into some additional ones that are custom made.

Read More

The lodash values method and native javaScript

The lodash values method is one of many methods in lodash where there is a native counterpart. However sometimes browser support for a native method only goes back so far, also sometimes a native method does not always work as expected, or it could use one more additional feature that is just not there. However the lodash values object method might not be the best example of the kind of method in lodash that brings something more to the table, as the lodash values method does more or less the same thing as the Object values method. However when it comes to going way back the native Object.values method is still fairly new, and as such the use of the Object values native method will result in code breaking in certain older browsers.

Still in nay case this will be a post on the lodash values method as well as the native javaScript counter part that is the Object.values static object method. There is also the lodash keys method as well as the the native Object.keys method that will return an array of public key names rather than values for a given object. Regardless if you use lodash or just native javaScript this is a method that any javaScript developer should be familiar with, alone with the Object keys method also. So lets take a look at some examples of the lodash values method.

Read More