Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Web Programming/JS Arrary

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Array Sort var points = [40, 100, 1, 5, 25, 10] points.sort((a, b) => a-b) console.log(points) runnable code Array Map Reduce array = [{x:1},{x:2},{x:4}] newValue = 2 result = array.map(item => item.x==newValue) .reduce((a,b)=>a||b) console.log(result) runnable code Array Filter array = [{x:1},{x:2},{x:4}] newValue = 1 newArray = array.filter(item => item.x>newValue) console.log(newArray) runnable code Array Push/Pop var fruits = ["Orange"] fruits.push("Kiwi") console.log(fruits) fruits.pop() console.log(fruits) runnable code Array Shift/Unshift var fruits = ["Orange", "Kiwi"] console.log(fruits) fruits.shift() console.log(fruits) fruits.unshift("Apple") console.log(fruits) runnable code