Found 9150 Articles for Object Oriented Programming

JavaScript toLocaleString() function

AmitDiwan
Updated on 17-Dec-2019 10:55:12

262 Views

The toLocaleString() method of JavaScript is used to convert a Date object to a string using locale settings.The syntax is as follows −Date.toLocaleString(locales, options)Above, the locales parameter is the language specific format to be used −ar-SA Arabic (Saudi Arabia) bn-BD Bangla (Bangladesh) bn-IN Bangla (India) cs-CZ Czech (Czech Republic) da-DK Danish (Denmark) de-AT Austrian German de-CH "Swiss" German de-DE Standard German (as spoken in Germany) el-GR Modern Greek en-AU Australian English en-CA Canadian English en-GB British English en-IE Irish English en-IN Indian English en-NZ New Zealand English en-US US English en-ZA English (South Africa) es-AR Argentine Spanish es-CL Chilean Spanish ... Read More

Convert an object to another type using map() method with Lambda in Java?

raja
Updated on 11-Jul-2020 06:13:04

9K+ Views

In Java 8, we have the ability to convert an object to another type using a map() method of Stream object with a lambda expression. The map() method is an intermediate operation in a stream object, so we need a terminal method to complete the stream.SyntaxStream map(Function

JavaScript Array.splice() Method

AmitDiwan
Updated on 17-Dec-2019 10:50:17

220 Views

The splice() method of JavaScript is used to add or remove item. It returns the removed item.The syntax is as follows −array.splice(index, num, item1, ....., itemX)Here, index is the integer specifying at what position to add or remove items, num is the number of items to remove, item1…itemX are the items to be added to the array.Let us now implement the splice() method in JavaScript −Example Live Demo Products Click to display the updated product list... Result    var products = ["Electronics", "Books", "Accessories"];    document.getElementById("test").innerHTML = products;    function display() {       products.splice(1, 2, ... Read More

JavaScript Array.prototype.map() function

AmitDiwan
Updated on 17-Dec-2019 10:44:09

136 Views

The Array.prototype.map() function of JavaScript is used create a new array with the results of called function.The syntax is as follows −arr.map(function callback(currentValue[, index[, array]])Let us now implement the Array.prototype.map() method in JavaScript −Example Live Demo Demo Heading Click to display the abs() result... Result    function display() {       var arr = [1, -2, 3, 4, 5, -6, 7, 8, 9, 10];       var res = arr.map(Math.abs);       document.write(res);    } OutputClick the “Result” button above −Example Live Demo Demo Heading Click to round the numbers... Result ... Read More

JavaScript Array.of() function

AmitDiwan
Updated on 17-Dec-2019 09:32:53

123 Views

The Array.of() method of JavaScript is used to create a new array instance with variables as parameter values.The syntax is as follows −Array.of(elements....)Above, elements are the values as parameter values.Let us now implement the Array.of() method in JavaScript −Example Live Demo    Demo Heading    Click the button to display the values in Console    Result               function display() {          console.log(Array.of(10, 20, 30, 40 ,50));       }     OutputClick the “Result” and check the Console for the output −Example Live Demo   ... Read More

JavaScript array.keys()

AmitDiwan
Updated on 17-Dec-2019 09:16:57

266 Views

The array.keys() method of JavaScript is used to return an Array Iterator object with the keys of an array.The syntax is as follows − array.keys()Let us now implement the array.keys() method in JavaScript −Example Live Demo    Car Variants               var arrStud = ["Crossover", "Convertible", "Hatchback", "SUV"];       var res = arrStud.keys();       for (val of res) {          document.getElementById("test").innerHTML += val + "";       }     OutputExample Live Demo    Ranking Points    Click the button to display ... Read More

JavaScript Array.isArray()

AmitDiwan
Updated on 17-Dec-2019 08:37:40

242 Views

The Array.isArray() method of JavaScript is used to determine whether an object is an array or not.The syntax is as follows −Array.isArray(ob)Above, the ob parameter is the object to be tested.Let us now implement the Array.isArray() method in JavaScript −Example Live Demo    Ranking Points    Is this an array? Click the below button to get the answer...    Result               var pointsArr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 1000];       var res = pointsArr.entries();       for (val of res) {       ... Read More

JavaScript array.includes() function

AmitDiwan
Updated on 17-Dec-2019 08:32:03

169 Views

The array.includes() method of JavaScript is used to check whether an array contains a specified element.The syntax is as follows −array.includes(ele, start)Above, the parameter ele is the element to search for. The start parameter is the position to begin the search with.Let us now implement the array.includes() method in JavaScript −Example Live Demo    Car Variant    Result               var carid = ["110", "230", "299", "399"];       document.getElementById("test").innerHTML = carid;       function display() {          var n = carid.includes("230");          document.getElementById("test").innerHTML = ... Read More

JavaScript array.flatMap()

AmitDiwan
Updated on 17-Dec-2019 08:25:08

271 Views

The array.flatMap() method of JavaScript is used to flatten the input array element into a new array.The syntax is as follows − array.flatMap(function callback(current_value, index, Array))Let us now implement the array.flatMap() method in JavaScript −Example Live Demo    Ranking Points    Is any point equal to 550 from the key-value pairs...    Result               var pointsArr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 1000];       var res = pointsArr.flatMap(val => [val + 10]).entries();       for (val of res) {          document.getElementById("test").innerHTML += ... Read More

JavaScript array.entries() Method

AmitDiwan
Updated on 17-Dec-2019 08:18:02

156 Views

The array.entries() method of JavaScript is used to return an Array Iterator object with key/value pairs.The syntax is as follows − array.entries()Let us now implement the array.entries() method in JavaScript −Example Live Demo    Ranking Points    Is any point equal to 550 from the key-value pairs...    Result               var pointsArr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 1000];       var res = pointsArr.entries();       for (val of res) {          document.getElementById("test").innerHTML += val + "";       }   ... Read More

Advertisements