Found 8591 Articles for Front End Technology

JavaScript symbol.description property

AmitDiwan
Updated on 17-Dec-2019 11:03:49

110 Views

The symbol.description property in JavaScript converts a Symbol object to a primitive value. The syntax is as follows −Symbol()[Symbol.toPrimitive](hint);Example Live Demo Demo Heading Click to display... Result    function display() {       const val = Symbol('john');       console.log(val[Symbol.toPrimitive]);    } OutputClick the “Result” button −Example Live Demo Demo Heading Click to display... Result    function display() {       const val = Symbol(2465);       var res = val[Symbol.toPrimitive](99);       console.log(res)    } OutputClick the “Result” button and get the result in Console −

JavaScript Array.prototype.values()

AmitDiwan
Updated on 17-Dec-2019 10:58:48

184 Views

The array.values() method of JavaScript returns a new Array Iterator object that contains the values for each index in the array.The syntax is as follows −arr.values()Let us now implement the array.values() method in JavaScript −Example Live Demo Demo Heading Click the button to display the value... Result    function display() {       var arr = ['p', 'q', 'r'];       var res = arr.values();       document.getElementById("test").innerHTML = res.next().value    } OutputClick on the “Result” button −Example Live Demo Ranking Points Click to display the points... Result   ... Read More

JavaScript toLocaleString() function

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

265 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

JavaScript Array.splice() Method

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

222 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

138 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

124 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

267 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

243 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

171 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

272 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

Advertisements