How to remove a specific key from Javascript Object?

In Javascript, You can remove/delete key-value pairs from the Object easily.

Just use, delete keywords with object.keyname or object['keyname']. delete used for removing a object key from given objects in Javascript.

Let’s take a simple object,

let xyz = {};
xyz.first = 1;
xyz.second = 2;
xyz.third = 3;
xyz.forth = 4;

Run console.log(xyz); Continue reading “How to remove a specific key from Javascript Object?”

Javascript forEach: How to iterate list items by Javascript?

You can iterate over given HTML list items using javascript by fetching li tags object with querySelectorAll()

Based on the response to the document.querySelectorAll() object, you need to convert the object to an array type that will be supported with forEach in javascript.

Let’s take a simple UL <LI> tag structure to fetch list items text value using forEach, Continue reading “Javascript forEach: How to iterate list items by Javascript?”

How to check radio button is checked/selected or not by Javascript only?

You can validate the radio button in a form is selected or not with the help of javascript.

<div class="radio-buttons">
      <div class="male">
        <input class="form-radio" type="radio" name="gender" id="radio1" value="male">
        <label class="form-check-label" for="radio1">Male</label>
      </div>

      <div class="female">
        <input class="form-radio" type="radio" name="gender" id="radio2" value="female">
        <label class="form-check-label" for="radio2">Female</label>
      </div>
</div>

Here you can check it by document.querySelectorAll() with the help of attribute name, Continue reading “How to check radio button is checked/selected or not by Javascript only?”