Array Helpers
JavaScript
var numbers = [1, 2, 3, 4, 5]
Array.prototype.square = function(){ return this.map(num => num ** 2) }
Array.prototype.cube = function(){ return this.map(num => num ** 3) }
Array.prototype.sum = function(){ return this.reduce((acc, curr) => acc + curr , 0) }
Array.prototype.average = function(){
return this.reduce((acc, curr) => acc + curr , 0) / this.length
}
Array.prototype.even = function(){ return this.filter(num => num % 2 === 0) }
Array.prototype.odd = function(){ return this.filter(num => num % 2 !== 0) }
console.log(numbers.square())
Also in JavaScript:
- Title
- how to use this in js
- Category
- JavaScript
- Title
- get number right of the dot length javascript
- Category
- JavaScript
- Title
- javascript and
- Category
- JavaScript
- Title
- how to create a variable in javascript
- Category
- JavaScript
- Title
- firebase cloud functions send email
- Category
- JavaScript
- Title
- Javascript check for hash in URL
- Category
- JavaScript
- Title
- how to align text inside react component
- Category
- JavaScript
- Title
- how to use chart js in vue js
- Category
- JavaScript
- Title
- how to push object in array using for loop javascript
- Category
- JavaScript
- Title
- how to append in javascript
- Category
- JavaScript
- Title
- javascript adding an array to an array
- Category
- JavaScript
- Title
- javacript count properties
- Category
- JavaScript
- Title
- angular calendar updating until hovering
- Category
- JavaScript
- Title
- file input disable open file picker javascript
- Category
- JavaScript
- Title
- a simple javascript calculator
- Category
- JavaScript
- Title
- javascript addeventlistener
- Category
- JavaScript
- Title
- if object is array javascript
- Category
- JavaScript
- Title
- how to define cardTitle background image in mdl in reactjs
- Category
- JavaScript
- Title
- discord.js dm user
- Category
- JavaScript
- Title
- inheritance in javascript
- Category
- JavaScript
- Title
- chai js
- Category
- JavaScript
- Title
- drupal 8 node has field
- Category
- JavaScript
- Title
- how to craete a shopping cart in node js
- Category
- JavaScript
- Title
- get the current url javascript
- Category
- JavaScript
- Title
- adding pre tag javascript
- Category
- JavaScript
- Title
- compare dates in js
- Category
- JavaScript
- Title
- get last element of array javascript
- Category
- JavaScript
- Title
- html to jsx
- Category
- JavaScript
- Title
- HTML5 Accesskey Attribute: you may not need JavaScript to add Keyboard Shortcuts
- Category
- JavaScript
- Title
- install php7 runtime brackets
- Category
- JavaScript
- Title
- add element to array javascript
- Category
- JavaScript
- Title
- access index of array javascript
- Category
- JavaScript
- Title
- how to get the value in a tag in react
- Category
- JavaScript
- Title
- history.pushstate
- Category
- JavaScript
- Title
- deploy angular app on google app engine
- Category
- JavaScript
- Title
- D3.js
- Category
- JavaScript
- Title
- javascript access php variable
- Category
- JavaScript
- Title
- how to read an array in javascript in HTML5
- Category
- JavaScript
- Title
- javascript after split then trim whitespace
- Category
- JavaScript
- Title
- form validation react
- Category
- JavaScript
- Title
- how to animate a flash in jquery
- Category
- JavaScript
- Title
- class javascript
- Category
- JavaScript
- Title
- ERROR in ./src/app/pages/auth/auth.module.ngfactory.js Module not found: Error: Can't resolve '@angular/material/core/index'
- Category
- JavaScript
- Title
- Can't bind to 'formGroup' since it isn't a known property of 'form'
- Category
- JavaScript
- Title
- angular bootstrap not working
- Category
- JavaScript
- Title
- flip a coin javascript
- Category
- JavaScript
- Title
- add new items in a select input using js
- Category
- JavaScript
- Title
- generate thumbnail of pdf using pf js
- Category
- JavaScript
- Title
- hide component on click vue
- Category
- JavaScript
- Title
- inner html jquery
- Category
- JavaScript
- Title
- axios delete request payload
- Category
- JavaScript
- Title
- how to use the foreach method in javascript
- Category
- JavaScript
- Title
- javascript ajax request
- Category
- JavaScript
- Title
- arrow function in javascript w3schools
- Category
- JavaScript
- Title
- how to call action from another module vuex
- Category
- JavaScript
- Title
- javascript add function to onchange event
- Category
- JavaScript
- Title
- callback in response node.js
- Category
- JavaScript
- Title
- how to make a screen recording software with js
- Category
- JavaScript
- Title
- how to setstate in parent in child component in react native
- Category
- JavaScript
- Title
- connect nodejs to mariadb
- Category
- JavaScript
- Title
- assign freemarker expressions to variables
- Category
- JavaScript
- Title
- How to rewrite a function using arrow function syntax
- Category
- JavaScript
- Title
- ISS proxy express
- Category
- JavaScript
- Title
- ellipsis javascript
- Category
- JavaScript
- Title
- disable input angular
- Category
- JavaScript
- Title
- how to remove a property from an object in javascript
- Category
- JavaScript
- Title
- angular npm angular material
- Category
- JavaScript
- Title
- adding bootstrap to angular
- Category
- JavaScript
- Title
- bubble sort javascript
- Category
- JavaScript
- Title
- angular moment pipe timeAgo
- Category
- JavaScript
- Title
- how to get value in array object value using for loop in javascript
- Category
- JavaScript
- Title
- dot geometru three js
- Category
- JavaScript
- Title
- angular add object to array
- Category
- JavaScript
- Title
- datatable on error.dt
- Category
- JavaScript
- Title
- how to convert audio blocb to base64 string
- Category
- JavaScript
- Title
- check window resize javascript
- Category
- JavaScript
- Title
- include jquery
- Category
- JavaScript
- Title
- document delete element
- Category
- JavaScript
- Title
- how to make a show password button
- Category
- JavaScript
- Title
- Javascript compare two dates
- Category
- JavaScript
- Title
- how to access array datat in class component react
- Category
- JavaScript
- Title
- how to save thing in cookie js
- Category
- JavaScript
- Title
- how to get element by title js
- Category
- JavaScript
- Title
- if condition in class angular 8
- Category
- JavaScript
- Title
- electron new window
- Category
- JavaScript
- Title
- gitignore for angular
- Category
- JavaScript
- Title
- create react app theme_color
- Category
- JavaScript
- Title
- express get url parameters
- Category
- JavaScript
- Title
- (not in PATH env variable)
- Category
- JavaScript
- Title
- ExoPlayer with auto linking react native
- Category
- JavaScript
- Title
- get today's date javascript
- Category
- JavaScript
- Title
- Alert.alert closing expo
- Category
- JavaScript
- Title
- ion-fab-button ionic angular
- Category
- JavaScript
- Title
- convert a int to a unicode javascript
- Category
- JavaScript
- Title
- add month date now javascript
- Category
- JavaScript
- Title
- get width of a dom element js
- Category
- JavaScript
- Title
- how to make a textarea unwritable in react native
- Category
- JavaScript
- Title
- fix your timestep javascript
- Category
- JavaScript
- Title
- d3 not reading json
- Category
- JavaScript
- Title
- bootstrap js cdn
- Category
- JavaScript