The JavaScript array.forEach() method doesn’t return anything!

A while ago working on a cool Angular2 project I discovered some weird behavior, weird because I didn’t realise it was working that way.

I was checking if an id property of an object, was already in an array. If it was, it won’t push it again. It is wasn’t in there, it could push the object in the array.

It doesn’t seem that difficult. So I created a little function so I could check it from anywhere in my application. (take into account that the code is from an Angular2 Typescript application.)

private doesFormExistsInSubmittedArray(list, val) {
    if (list !== undefined && list.length > 0) {
        list.forEach(function (item, index, arr) {
            if(item.formObject.id === val.id) {
                return true;
            }
        });
    }
    return false;
}

Read more

Frontend Workflow #2: CSS automation with GulpJS

This post originally published on the Mr Frontend Community Blog!

This is the second episode of  the “Frontend Workflow” series. In this episode, I will use GulpJS, some plugins and Browser-sync to show you how you can automate your CSS development in your workflow.

Read more