Why is using “for…in” for array iteration a bad idea in JavaScript?

The purpose of the for-in statement is to enumerate over object properties. This statement will go up in the prototype chain, also enumerating over inherited properties, a thing that sometimes is not desired. There are three reasons why you shouldn’t use for..in to iterate over array elements: for..in will loop over all own and inherited Read More…


Center image in div vertically and horizontally | Example code

Center image in div vertically and horizontally use margin: auto; in CSS. In HTML webpage set left and right margin to auto and make it into a block element. Simple Example code: Image is in a same folder with webpage. Output: Example of CSS center image in div Example code of CSS center image vertically Read More…


Example div fill height | child div fill parent height

How to make the main content div fill the height of the screen with CSS? Let’s see one example, the webpage has divided into 3 parts:- A header, mainbody, and footer. We want the mainbody to fill 100% of the page (fill 100% in between footer and header). Here is code Stretch div using bottom Read More…


Horizontal align CSS | How to Horizontally center a

Horizontal align CSS To Center Align Elements in HTML (like), use CSS code margin: auto;. Try to set the width of elements, it will prevent them from stretching out to the edges of its container. You can do align div, text, image elements by suing CSS. Horizontally Center Align Text To just center the text Read More…


CSS text vertical-align | HTML Example code

There are many ways to Align text using CSS in HTML. You can align vertical text in <div> using simply CSS approaches, Someway are:- Before start you must know about CSS – What is CSS? Basic approach – For single line only Versatile approach – single line and multiple lines of text Simulating table display Read More…


Align div in center Using CSS | Example Code

Center div An absolutely positioned element acts the same for the distribution of free space, and similarly can be centered vertically at the specified top and bottom. The trick of aligning div in the center: (The best and most flexible way example code). Output: Note: only works if your element has a fixed height. How Read More…