Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Known JavaScript Array Reduce For Plain JavaScript Objects

License

NotificationsYou must be signed in to change notification settings

graef685/ReduceObject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Plain JavaScript objects reduce as known from the Array.prototype

Release with Dependencies !!!

If you include thejquery.reduce-object.min.js only, be sure jQuery is part of your Project.
You will get it here:

Install - Demo

  • Download
  • npm install

Run - Demo

  • node server.js
  • Open your browser atlocalhost:1234

API

varresult=$.reduceObject(obj,callback,acc);

ThereduceObject function takes following arguments:

obj:      {Object}-> the object to reducecallback: {function}-> the function to reduce withacc:      {*}-> the initial value given the first iteration as 'dest' argument

Thecallback function receives following arguments:

dest-> previous valuecurr-> actual valuein iterationkey-> actual keyin iterationobj-> the original object

Usage

  • Includejquery.reduce-object.min.js into your Project
varobjA={    keyA={value:2},    keyB={value:9}};varresult=$.reduceObject(objA,function(dest,curr,key,obj){dest+=curr;returndest;},{value:31});console.log(result);// { value: 42 }

Contributors

About

Known JavaScript Array Reduce For Plain JavaScript Objects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp