AmitDiwan has Published 10740 Articles

Can JavaScript parent and child classes have a method with the same name?

AmitDiwan

AmitDiwan

Updated on 14-Sep-2020 08:42:46

1K+ Views

Yes, parent and child classes can have a method with the same name.Exampleclass Parent {    constructor(parentValue) {       this.parentValue = parentValue;    }    //Parent class method name which is same as Child Class method name.    showValues() {       console.log("The parent method is called....."); ... Read More

How can I filter JSON data with multiple objects?

AmitDiwan

AmitDiwan

Updated on 14-Sep-2020 08:40:38

17K+ Views

To filter JSON data with multiple objects, you can use the concept of filter along with ==.Exampleconst jsonObject= [    {       studentId:101,       studentName:"David"    },    {       studentId:102,       studentName:"Mike"    },    {       studentId:103,   ... Read More

Display the Asian and American Date Time with Date Object in JavaScript

AmitDiwan

AmitDiwan

Updated on 14-Sep-2020 08:39:14

2K+ Views

For this, you can use timeZone from JavaScript i.e. specific time zones for Asia and America respectively.For Asian Time Zonevar todayDateTime = new Date().toLocaleString("en-US", {timeZone: "Asia/Kolkata"});For American Time Zonevar americaDateTime = new Date().toLocaleString("en-US", {timeZone: "America/New_York"});Examplevar todayDateTime = new Date().toLocaleString("en-US", {timeZone: "Asia/Kolkata"}); todayDateTime = new Date(todayDateTime); console.log("The Asia Date time is="); ... Read More

Display the dropdown’s (select) selected value on console in JavaScript?

AmitDiwan

AmitDiwan

Updated on 14-Sep-2020 08:37:45

3K+ Views

Let’s say the following is our dropdown (select) −    Javascript    MySQL    MongoDB    Java Following is the code to display the selected value on Console −Example Live Demo Document Javascript MySQL MongoDB Java    function ... Read More

Local Variable Type Inference or LVTI in Java 10

AmitDiwan

AmitDiwan

Updated on 14-Sep-2020 08:36:17

467 Views

Type inference in Java refers to the automatic detection of the variable’s datatype. This automatic detection usually happens at compile time. It is a feature of Java 10 and it allows the developer to skip declaring the type that is associated with the local variables. Local variables are those which ... Read More

How can we invoke the parent's method, when a child has a method with the same name in JavaScript?

AmitDiwan

AmitDiwan

Updated on 14-Sep-2020 08:31:46

1K+ Views

In order to call the parent method when both parent and child have the same method name and signature.You can use the below syntax −console.log(yourParentClassName.prototype.yourMethodName.call(yourChildObjectName));Exampleclass Super {    constructor(value) {       this.value = value;    }    display() {       return `The Parent class value is= ... Read More

Length of a JavaScript object?

AmitDiwan

AmitDiwan

Updated on 14-Sep-2020 08:30:25

225 Views

Let’s say the following is our Student object −var studentObject = new Object(); studentObject["studentFirstName"] = "John"; studentObject["studentLastName"] = "Doe"; studentObject["studentAge"] = 22; studentObject["studentCountryName"] = "US"; studentObject["studentCollegeName"] = "MIT"; studentObject["studentSubjectName"] = "JavaScript";Let’s find the length.You can use the concept of keys available in object and if the key is present then ... Read More

How to combine two arrays into an array of objects in JavaScript?

AmitDiwan

AmitDiwan

Updated on 14-Sep-2020 08:27:05

3K+ Views

Let’s say the following are our two arrays −var firstArray = ['John', 'David', 'Bob']; var secondArray = ['Mike', 'Sam', 'Carol'];To combine two arrays into an array of objects, use map() from JavaScript.Examplevar firstArray = ['John', 'David', 'Bob']; var secondArray = ['Mike', 'Sam', 'Carol']; var arrayOfObject = firstArray.map(function (value, index){   ... Read More

How to make my textfield empty after button click in JavaScript?

AmitDiwan

AmitDiwan

Updated on 14-Sep-2020 08:24:19

2K+ Views

For this, you can use onclick=”yourFunctionName()”, and −document.getElementById(“”).value=’’Example Live Demo Document ClearInputText    function clearTheTextField(){       console.log("The text box       value="+document.getElementById('txtBox').value)       document.getElementById('txtBox').value = '';    } To run the above ... Read More

Java Program for Radix Sort

AmitDiwan

AmitDiwan

Updated on 14-Sep-2020 08:21:15

496 Views

Radix sort is a sorting technique that sorts the elements based on every digit in every element (or number). Based on the ones place digit (which is also known as least significant digit) and tens place digit (which is also known as most significant digit), hundreds place digit, and so ... Read More

Advertisements