
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10483 Articles for Web Development

143 Views
For this, use Object.keys() as well as Object.values() and map() for the result.Exampleconst object = { name: 'John', age: 21, countryName: 'US', subjectName: 'JavaScript' } const allKeysOfObject = Object.keys(object); console.log("The all keys are=" + allKeysOfObject); const allValues = Object.values(object); console.log("The all values are=" + allValues); console.log("The use of map is as follows="); allKeysOfObject.map(k => { console.log(object[k]) })To run the above program, you need to use the following command −node fileName.js.Here, my file name is demo185.js.OutputThis will produce the following output −PS C:\Users\Amit\javascript-code> node demo185.js The all keys are=name, age, countryName, subjectName The all values are=John, 21, ... Read More

997 Views
You can use simple for loop along with some if else condition to get the array’s first element in JavaScript.The logic is that, first of all check the array length is greater than 1 or not if the length is not equal to 1 that means there is no element in the array. So, go to the else condition and set the value undefined and print any message at the console. If there is an element in an array, set the first index value to any variable and terminate the loop with the help of break and print the message ... Read More

245 Views
For this, use map() along with find(). Following is the code −Examplevar details1 = [ { productDetails: { isSold: true, productId:101 } }, { productDetails: { isSold: true, productId:103 } } ] var details2 = [ { productDetails: { isSold: false, productId:101 } } ] var details3 = details1.map(details1Object=>{ var newObject= details2.find(obj=>obj.productDetails.productId === details1Object.productDetails.productId) return newObject? newObject : details1Object }) console.log(details3)To run the above program, you need to use the following command −node fileName.js.Here, my file name is demo183.js.OutputThis will produce the following output −PS C:\Users\Amit\javascript-code> node demo183.js [ { productDetails: { isSold: false, productId: 101 } }, { productDetails: { isSold: true, productId: 103 } } ]

293 Views
To declare and define multiple variables in one statement, you can use below syntax −var anyVariableName1=yourValue1, anyVariableName2=yourValue2, anyVariableName3=yourValue3, anyVariableName4=yourValue4, . . NExamplevar firstName="My First Name is David", lastName="My Last Name is Miller", place="I live in AUS"; console.log(firstName); console.log(lastName); console.log(place);To run the above program, you need to use the following command −node fileName.js.Here, my file name is demo182.js.OutputThis will produce the following output −PS C:\Users\Amit\javascript-code> node demo182.js My First Name is David My Last Name is Miller I live in AUSRead More

328 Views
To check whether a checkbox is checked in jQuery, use the concept of toggle(). Following is the code −Example Live Demo Document Your name is Adam Smith $('#selectName').click(function() { $("#txtName").toggle(this.checked); }); To run the above program, just save the file name anyName.html(index.html) and right click on the file and select the option open with live server in VS Code editor.OutputThis will produce the following output −When you select the check box, the following will be the output −

659 Views
Let’s say the following is our dropdown − John David Chris Mike Bob Carol Following is our array −var listOfNames = ["Chris", "Robert", "Mike"];To check whether the selected list value contains a value in array, use −$(‘select’).on(‘change’).Example Live Demo Document John David Chris Mike Bob Carol var listOfNames = ["Chris", "Robert", "Mike"]; $('select').on('change', function() { var name = this.value.split(' ')[0]; if($.inArray(name, listOfNames) > -1) { console.log('This is present in list ... Read More

472 Views
A DB2 collection is a physical quantity which is used to group the packages. A collection can be simply termed as a group of DB2 packages. By using collections we can bind the same DBRM into different packages. In order to delete all the DB2 packers under a collection, we can issue below command.FREE PACKAGE(COLL1.*)The FREE PACKAGE reserved word is followed by the name of collection i.e. COLL1. The * after the collection name indicates that we need to perform delete action for all the packages under the said collection.

227 Views
Let’s say the following is our list −var details=[ {id:101, name:"John", age:21}, {id:111, name:"David", age:24}, {id:1, name:"Mike", age:22}, {id:"", name:"Sam", age:20}, {id: 1, name:"Carol", age:23}, {id:null, name:"Robert", age:25}, {id:1, name:"Adam", age:24}, {id:"", name:"Chris", age:23} ];You can use the concept of filter to retrieve values based on specific ID.Examplevar details=[ {id:101, name:"John", age:21}, {id:111, name:"David", age:24}, {id:1, name:"Mike", age:22}, {id:"", name:"Sam", age:20}, {id: 1, name:"Carol", age:23}, {id:null, name:"Robert", age:25}, {id:1, name:"Adam", age:24}, {id:"", name:"Chris", age:23} ]; var getIdWithValue1 = details.filter(obj => obj.id === 1); console.log(getIdWithValue1);To ... Read More

596 Views
Let’s say the following are our coordinates −var listOfStrings = ["10.45322, -6.8766363", "78.93664664, -9.74646646", "7888.7664664, -10.64664632"];To convert the above into two float lists of Latitude and Longitude, use split() on the basis of comma(, ) along with map().Examplevar listOfStrings = ["10.45322, -6.8766363", "78.93664664, -9.74646646", "7888.7664664, -10.64664632"]; var latitude = []; var longitude = []; listOfStrings.forEach(obj => obj.split(', ') .map(Number) .forEach((value, index) => [latitude, longitude][index].push(value)) ); console.log("All positive value is latitude=") console.log(latitude); console.log("All negative value is longitude=") console.log(longitude);To run the above program, you need to use the following command −node fileName.js.Here, my file name is demo180.js.OutputThis will produce the following output ... Read More

375 Views
To ignore a specific value, use the logical Not (!) operator in if condition and fetch watching you want to include.Examplevar customerDetails=[ { customerName:"John", customerAge:28, customerCountryName:"US" }, { customerName:"David", customerAge:25, customerCountryName:"AUS" }, { customerName:"Mike", customerAge:32, customerCountryName:"UK" } ] for(var i=0;i node demo179.js The country name is=US The country name is=UK