Mar 15Sort Array of Strings in JavaScriptHere I’m sharing three ways to sort an array of strings in JS. Approach 1: We can directly use the inbuilt methods of array objects in JS. If we want to sort in ascending order we can simply use the Sort method and Reverse method for descending order. For example…Array Of String2 min readArray Of String2 min read
Feb 27Optimize complex if-else statements in JavaScriptSometimes we have to write complex if-else statements to verify multiple conditions. For e.g., I have a function that returns the discount price based on the coupon code provided by the user. Here have to verify each and every statement which takes a long time. Approach 1 : The first way to optimize this issue is by using a switch case. In which we don’t need to verify each and every statement. Instead based on the coupon code we can directly jump to the respective condition.Nested If Else2 min readNested If Else2 min read
Feb 3How to improve the unit test running time in AngularWhat is Unit Testing in Angular? Unit testing in Angular refers to the practice of testing individual components, services, pipes, and other units of an Angular application in isolation from the rest of the application. …Unit Testing3 min readUnit Testing3 min read
Jun 23, 2022How to automate running of Apache and MySQL in XAMPP1. Open notepad and enter the below commands start C:\xampp\xampp-control.exe 2. Save as .bat file 3. Open your XAMPP application, click on ‘config’ button. 4. Check the check boxes of required servers.Xampp1 min readXampp1 min read
Jun 2, 2022Maintain history of copied text and save your time in copy-pasting.If you are working projects, where you’ve copy paste couple of text multiple times, here is the hack. How to Save the copied text (Ctrl + C): 1. Click on Windows key in keyboard. 2. Search for Clipboard Settings or you can also find this under System > Clipboard in settings. 3. Toggle the `on` button of the Clipboard history.Copypaste2 min readCopypaste2 min read
May 28, 2022Add key-value pair to every object in array of objects in JavaScriptSometimes, we’ve to add flag or some new key-value pair to every object in array of objects. For that we can follow three ways to achieve it. For suppose, we have an array of objects as below and we want to add gender key to all the objects. students =…Key Value Pair2 min readKey Value Pair2 min read
May 20, 2022Avoiding multiple API calls in Angular by using shareReplay method of RxJSWhile working with some Angular projects, we’ve to subscribe the same API in to different methods in a component. In order to avoid that we can use shareReplay method of RxJS. Lets consider an app which has two buttons and two different methods gets called on clicking on those buttons…Ngrx3 min readNgrx3 min read
May 17, 2022Extract list of values from an array of objects to an array based on a key in JavaScript.There may be a situation where you want to extract the list of values of a specific key from an objects to an array. Method 1: In one way, we can use both for loop and Array.push() method and achieve it. For example, we have an Array of objects as…Array Of Object2 min readArray Of Object2 min read
Mar 17, 2021Angular Interview QuestionsIf you are here reading this post, you might be preparing for interviews. I hope that I’ll jot down the most frequently asked interview question and answers for both Freshers and Experienced as of 2021. Hope this article will help you in cracking your dream job. What is Angular? Angular…Angular4 min readAngular4 min read