javaScript – Replace all occurrences of a forward slash in a string

Rajesh/ June 26, 2020

Today I learned an easy solution to replace all occurrences of a forward slash in string in javascript. I had to convert an URL to a string in another format, so initially, I tried str.replace() method like But to my surprise, it only replaced the first occurrence in the string.Then I thought oh I might need to use a regular

Read More

Introduction to the javascript fetch() Api

Rajesh/ June 10, 2020

The Fetch api is used to fetch data or resources from a server. It allows us to retrieve data from a URL without having to do a full page refresh. The Fetch api is an improvement over the XMLHttpRequest API (XHR). Here is a basic example of XMLHttpRequest. Example from MDN docs. And a simple fetch request looks like: fetch method accepts

Read More

Responsive images – Using Srcset

Rajesh/ May 31, 2020

Srcset is a property that we can use with img tag. It lets us list a set of images which we want to load at different resolutions for an image. For example: The browser chooses one from the list and then fetches the image based upon the viewport dimensions, the image size relative to the viewport, the pixel density of

Read More

Responsive Web Design – Media Queries

Rajesh/ May 19, 2020

Media queries help us determine the layout of our application based on various device types, specific characteristics and parameters such as screen resolution or device orientation. We can use media queries in CSS, HTML and javascript. CSS: We can use media queries in CSS with the @media at-rule. The @media rule allows us to conditionally apply parts of a style

Read More