["1", "2", "111"].map(parseInt); // returns [1, NaN, 7]
Have you ever tried passing
parseInt to array’s
map method ?
If not yet, I will say try it now. It’s very interesting.
When we try it for first time, it looks very confusing but once we understand the logic, it becomes easy to understand.
To understand how this works we need to understand how
map method and
It creates a new array after executing a callback function on every array elements. Three parameters are passed to that callback function.
In our case that callback function is
parseInt will be called on each array element and it’s result will be added in newly created array. …
Why to reinvent the wheel ?
Lots of good things are built in the world. If we can use them, why to re-create them every time? We should use those things to create something new.
The same logic is applicable in front end development as well. Whenever we work on any front end project, we use lots of third-party
npm packages for various purposes.
One day I was setting up one of my new mini-project to learn
Redux Saga. I realized that these
npm packages are really cool. Those packages are developed by some developers and used by anyone throughout the world. Just import it and use it. …
To achieve anything big in our life we have to be disciplined. We have to set some rules and we have to follow them no matter what happens. So to define strict in simple terms, it’s just rule, rule and rules. These rules help us to avoid the known mistakes.
To declare the
strict mode you just have to add
'use strict'; at start of file or at start of functions. We can impose the
strict mode at file level or at function level. Ideally strict mode should be on file level but if we are having a legacy code and file is big, it will take a lot of time to resolve the issues highlighted by
strict mode. In such cases
strict mode should be used on function level and gradually it should be kept on file level. …
People do lots of things to get kicks. I am not talking about physical kicks but about mental kicks.
For such kicks someone drinks coffee, someone drinks tea, someone smokes and someone do something unique. Everyone has their own way to get kicks.
Kicks give us instant energy. It makes our mood happy. It increases our productivity for a while. We feel like this is what we needed to feel better.
Sometime in our career, time comes that we need to be at our top speed. At such time what we desperately needs is KICK.
Whenever such time comes to me, I listen some songs which I have collected till now. For me, these songs act like a kick. …
Unit testing is one of the most important part of any application development. It helps us to make our source code more robust. Purpose of this article is to cover Jasmine test cases for core component of Angular Application.
Angular-CLI. i.e. All dependencies are installed and
Karmaconfig is ready.
globalmocks.ts which will be keeping all test data and other global mocks. Make sure to export data and mocks. There are different levels of mock in case of callback functions.
When you create a new component using
ng component new <component_name> command, it will create component as well as spec file for that component. Ex. your component file name is
home.component.ts then spec file name will be
In Angular, component communication is a very essential thing. For component communication, we use
@Input(). This works well if our application is small. But as our application grow, more and more components are added. So we have to add lots of
@Input() at many levels which becomes very difficult to manage. Debugging an issue in lots of
@Input() levels is a nightmare.
There are multiple ways to resolve this issue but in this blog we are focusing on component communication using
RxJS is simply a library of event management).
This implementation consists of three…
Visual Studio Code is the best IDE for any front end development. During the code development we do lots of things other than coding. Things like formatting, making builds and much more. To help the developers speed up there are lots of extensions available for Visual Studio Code.
I have listed down extensions which I believe will definitely help during front end development:
Originally published at https://yuvi1422.blogspot.com on March 24, 2020.
Writing unit test always help in longer run. Now a days almost all frameworks and libraries are supporting unit testing. In React Bootstrap, there is documentation for using the unit test cases but still writing unit test cases for React-Bootstrap Modal can get confusing.
After spending hours on it finally I am able to write test cases for it. These code snippets can be used for other React-Bootstrap components as well (by changing the corresponding names).
Happy Unit Testing.
Originally published at https://yuvi1422.blogspot.com on August 25, 2019.