ring

Antibody-labeled Gold Nanoparticles Based Resonance Rayleigh Scattering Detection of S100B

Anal. Methods, 2024, Accepted Manuscript
DOI: 10.1039/D4AY00335G, Paper
tiantian Wang, yonghui Wang, junbo Li
Traumatic brain injury (TBI) is a sudden brain injury due to an external force that causes a large number of deaths and permanent disabilities every year. S100B has been recognized...
The content of this RSS Feed (c) The Royal Society of Chemistry




ring

Three-dimensional hotspot structures constructed from nanoporous gold with a V-cavity and gold nanoparticles for surface-enhanced Raman scattering

Anal. Methods, 2024, Advance Article
DOI: 10.1039/D4AY00348A, Paper
Yang Xu, Yan Wu, Jianjun Wei, Yuanyu Zhao, Peili Xue
A nanoporous gold V-shaped resonant cavity (NPGVRC) structure constructed with plasmonic resonance coupling effect. The NPGVRC has excellent SERS performance and 3D hotspot properties.
To cite this article before page numbers are assigned, use the DOI form of citation above.
The content of this RSS Feed (c) The Royal Society of Chemistry




ring

Monolith stationary phases prepared via cyclic anhydride ring-opening polymerization as tunable platforms for chromatographic applications

Anal. Methods, 2024, Accepted Manuscript
DOI: 10.1039/D4AY00251B, Paper
Ahmad Aqel, Ayman Ghafr, A. Yacine Badjah-Hadj-Ahmed, Zeid Abdullah ALOthman
Polymer monolithic stationary phases were prepared based on a cyclic anhydride as a reactive and tunable platform via ring-opening post-polymerization using primary amines; octadecylamine and benzylamine. The characterization techniques indicated...
The content of this RSS Feed (c) The Royal Society of Chemistry




ring

Design, synthesis, inhibitory activity, and molecular simulations study for D-glucose-conjugated thioureas containing pyrimidine ring as multitarget inhibitors against α-amylase, α-glucosidase, DDP-4, and PTP1B in Type 2 diabetes mellitus

RSC Med. Chem., 2024, 15,3395-3417
DOI: 10.1039/D4MD00334A, Research Article
Vu Ngoc Toan, Do Son Hai, Hoang Thi Kim Van, Nguyen Minh Tri, Duong Ngoc Toan, Nguyen Thi Thanh Mai, Nguyen Dinh Thanh
D-Glucose-conjugated thioureas from 2-aminopyrimidines had inhibitory activity against α-amylase, α-glucosidase, DPP-4, PTP1B. The cytotoxicity, inhibitory kinetics, and molecular simulations of the most potent inhibitors 8k, 8j, 8f, and 8h were studied.
The content of this RSS Feed (c) The Royal Society of Chemistry




ring

Exploring apoptotic induction of malabaricone A in triple-negative breast cancer cells: an acylphenol phyto-entity isolated from the fruit rind of Myristica malabarica Lam.

RSC Med. Chem., 2024, 15,3558-3575
DOI: 10.1039/D4MD00391H, Research Article
Pothiyil S. Vimalkumar, Neethu Sivadas, Vishnu Priya Murali, Daisy R. Sherin, Madhukrishnan Murali, Anuja Gracy Joseph, Kokkuvayil Vasu Radhakrishnan, Kaustabh Kumar Maiti
Malabaricone A isolated from Myristica malabarica induces apoptosis in triple-negative breast cancer cells through intrinsic and extrinsic pathways, which is validated through in vitro and in silico studies and resembles a potent phyto-entity.
The content of this RSS Feed (c) The Royal Society of Chemistry




ring

Exploring 7β-amino-6-nitrocholestens as COVID-19 antivirals: in silico, synthesis, evaluation, and integration of artificial intelligence (AI) in drug design: assessing the cytotoxicity and antioxidant activity of 3β-acetoxynitrocholestane

RSC Med. Chem., 2024, Advance Article
DOI: 10.1039/D4MD00257A, Research Article
Shahabuddin, Uzma, Mohammad Azam, Mehtab Parveen, Nurul Huda Abd Kadir, Kim Min, Mahboob Alam
In light of the ongoing pandemic caused by SARS-CoV-2, effective and clinically translatable treatments are desperately needed for COVID-19 and its emerging variants.
To cite this article before page numbers are assigned, use the DOI form of citation above.
The content of this RSS Feed (c) The Royal Society of Chemistry




ring

Synthesis and biological evaluation of novel D-ring fused steroidal N(2)-substituted-1,2,3-triazoles

RSC Med. Chem., 2024, Advance Article
DOI: 10.1039/D4MD00297K, Research Article
Branislava Tenjović, Sofija Bekić, Andjelka Ćelić, Edward Petri, Julia Scholda, Florian Kopp, Marija Sakač, Andrea Nikolić
In this study, a series of 13 new D-ring fused steroidal N(2)-substituted-1,2,3-triazoles were synthesized, characterized and evaluated for their biological activities.
To cite this article before page numbers are assigned, use the DOI form of citation above.
The content of this RSS Feed (c) The Royal Society of Chemistry




ring

Medicinal chemistry-based perspective on thiophene and its derivatives: Exploring the structural insights to discover plausible druggable leads

RSC Med. Chem., 2024, Accepted Manuscript
DOI: 10.1039/D4MD00450G, Review Article
Shikha Thakur, Devendra Kumar, shivani jaiswal, Kapil Kumar Goel, Pramod Rawat, Vivek Srivastava, Sonia Dhiman, Hemant R Jadhav, Ashish Ranjan Dwivedi
Thiophene is a privileged pharmacophore in medicinal chemistry owing to its diversified biological attributes. The thiophene moiety has been ranked 4th in US FDA drug approval of small drug molecules,...
The content of this RSS Feed (c) The Royal Society of Chemistry




ring

S-MGBs bearing amidine tail groups are potent, selective antiplasmodial agents

RSC Med. Chem., 2024, Advance Article
DOI: 10.1039/D4MD00619D, Research Article
Open Access
  This article is licensed under a Creative Commons Attribution 3.0 Unported Licence.
Marina Perieteanu, Tayner Rodriguez Garzon, Leah M. C. McGee, Abedawn I. Khalaf, Colin J. Suckling, Rebecca Beveridge, Vicky M. Avery, Fraser J. Scott
25 S-MGBs, including those bearing an amidine tail group, were investigated for their antiplasmodial, in vitro activity against 3D7 and Dd2 strains of P. falciparum. Several potent, and selective, hit compounds were identified.
To cite this article before page numbers are assigned, use the DOI form of citation above.
The content of this RSS Feed (c) The Royal Society of Chemistry




ring

Will decide on sharing stage with actor Vijay in consultation with VCK leaders: Thirumavalavan

Mr. Thirumavalavan told reporters in Tiruchi that the book release event was not something that was planned recently, and that he had consented to take part in it almost a year ago




ring

Ernakulam Express to stop at Muthupettai during Kandhoori festival




ring

HR&CE plans to bring properties around the Vennaimalai Temple under tenants list

The HR&CE department has cleared 34 properties around the Balasubramanyaswamy Temple at Vennaimalai in Karur district as per the High Court orders




ring

Students and agriculture officials grapple with logistical, technical issues during digital crop survey




ring

567: Full Stack Dev, Load Bearing Developer, and Being Zod Curious

What do you do if your computer dies? Chris applies to work at Luro, Dave applies at CodePen, Dave's Zod curious, TypeScript, sorting out a 10MB blog post, and how much do you miss jQuery?




ring

581: DevRel, Musical Mics, Social Sharing, and 100 Years of WordPress

Dave calls a quick Luro branding meeting, some thoughts on DevRel, Chris tries to figure out musical instrument mics, follow up on WordPress from a previous episode, Chris' journey through the social graph options, 100 year hosting with WordPress, and the introduction of a new segment: Happy Project Share Time.




ring

608: Can WordPress Kill Your Resume, Fav Parts of Web Dev, Exploring HTMX, and more!

We're opening up the ShopTalk mailbag and answering your questions, including does WordPress on your resume kill your job chances, what are our fav and least fav parts of web dev, our thoughts on HTMX, and what is it like to use pnpm instead of npm.




ring

621: Setting Up Prettier and Linting, Comparing Colors, and Accessibility Overlays

We've got follow up on Cloudflare and Cara from last episode, a question about setting up Prettier and auto linting, a cool tool from a listener on comparing colors, a question about using tooling like Craft or more user friendly apps like Webflow when working with clients, and our takes on accessibility overlays.




ring

622: Website Rendering, Updating Software, and Edge Gets Faster

We're talking website rendering, server side rendering, Astro's server islands, perf hits for navigation elements, updating software because the docs aren't available for older versions, and a new Microsoft Edge was released.




ring

Ferrari's Leclerc fined for swearing

Stewards at the Brazilian race summoned Leclerc on Friday, acting on a report from the governing FIA's media delegate and after reviewing a written transcript.




ring

The secret sauce behind ITC’s enduring restaurant brands

The promise of an unchanged, consistent menu and supreme culinary artistry has drawn food lovers to ITC’s tables for decades




ring

How Jio is powering Reliance’s media, entertainment biz

Despite a late entry into telecom, digital services, and media, Reliance has raced to the top




ring

Haryana Congress to move court over ‘violations’ by BJP during Assembly poll

Panel to gather information from party’s candidates about various violations




ring

Leaves taken by doctors during RG Kar protest to be adjusted against their official quota: AIIMS Delhi




ring

Delhi cop Nidhin Valsan’s inspiring journey from arresting cancer to Ironman finish line

Diagnosed with stage 4 non-Hodgkin’s lymphoma in 2021, IPS officer Nidhin Valsan resurrected himself by competing the Ironman triathlon and writing his memoir because he hopes to be a good influence on other cancer patients




ring

Delhi | The DAG is hosting an exhibition that celebrates MF Husain and his enduring legacy 

An exhibition in New Delhi’s DAG covers pivotal moments of legendary artist and painter MF Husain’s artistic journey 




ring

One dead, one injured in two firing incidents in Delhi within 10 minutes

The two incidents of firing in northeast Delhi leave one dead and one injured; three suspects apprehended by police




ring

ARRL VEC Services Update During Systems Disruption

Updated 10/30/2024

ARRL previously reported that we are responding to a serious incident involving access to our network and headquarters-based systems. Several services have been affected, including those administered by the ARRL Volunteer Examiner Coordinator (ARRL VEC).

Exam Registrations and Materials. ARRL Volunteer Examiners (VEs) should continue to submit exam registrations and material re...




ring

ARRL Recognizes University of Scranton During Amateur Radio Station Dedication

The University of Scranton in Pennsylvania has a new amateur radio station, W3USR. A dedication was held at the university’s Loyola Science Center on Friday, October 25, 2024, led by Dr. Nathaniel Frissell, W2NAF, an associate professor of physics and electrical engineering, and club advisor for the University of Scranton Amateur Radio Club.

The new W3USR University of Scranton Amateur Radio Sta...




ring

Strategies for an enduring legacy

How firms can thrive in an era of social tension, economic nationalism and tech revolution




ring

Exploring India’s diversity

A corporate honcho’s reflections on business and beyond




ring

Booming Digital Stars: 11 Inspiring Journeys from India’s Creator Economy 

Lessons from the exciting success stories of social media influencers




ring

Tobacco Board authorises 100 million kg crop size for Karnataka during 2024-25

Registration process for upcoming crop season will commence on March 27




ring

Eyebrows raised as Central team visits Anantapur to assess rabi drought during rainy kharif

The team choosing mandals like Vidapanakallu and Vajrakarur which received excessive rain in June, draws flak from farmers and district officials alike; farmers worry as to how to present their drought woes to the officials who are visiting their fields which are now rain-fed and green




ring

BJP protecting SEBI chairperson Madhabi Puri Buch from answering to PAC: Congress

Leader of the Opposition in the Lok Sabha Rahul Gandhi said Ms. Buch was being protected from giving answers to Parliament, from resigning as SEBI chief and from an investigation into her alleged links with the Adani Group companies. Ms. Buch had skipped the PAC meeting citing personal reasons




ring

Tamil Nadu airport infrastructure: Excitement in the air — preparing the ground for take off

Air travel in Tamil Nadu could see a boom over the next few years as significant infrastructure development is in the offing at airports in tier 2 cities across the State. With the State government keen on ensuring distributed growth, strengthening the aviation infrastructure could be a stimulus to the regional economic development as enhanced air connectivity is expected to help attract investment, trade, and tourism




ring

Three engineering students drown in Cauvery river in Namakkal

Jedarpalayam police registered a case and are investigating




ring

Heavy rainfall forecast for Chennai, neighbouring districts till November 15

Chennai district collector has declared holiday for schools on November 12 owing to rain




ring

Chennai and neighbouring districts to witness heavy rains till November 15

On Nov. 12, RMC, Chennai, upgraded its weather warning to orange alert, indicating a possibility of rainfall of very heavy intensity for 24 hours ending 8.30 a.m. on Nov. 13 in Chennai, Tiruvallur, and Chengalpattu districts




ring

Carboxymethyl cellulose-stabilized calcium phosphate particles for injectable hydrogel-based bone tissue engineering

Soft Matter, 2024, Advance Article
DOI: 10.1039/D4SM00670D, Paper
Piyaporn Srisura, Yuwaporn Pinyakit, Umphan Ngoensawat, Pongsakorn Yuntasiri, Khoiria Nur Atika Putri, Theerapat Chanamuangkon, Waranyoo Phoolcharoen, Varol Intasanta, Voravee P. Hoven
Carboxymethyl cellulose-stabilized calcium phosphate particles well-dispersed in aqueous solution can be integrated into an injectable hydrogel made of methacrylated hyaluronic acid which is a promising material for bone regeneration applications.
To cite this article before page numbers are assigned, use the DOI form of citation above.
The content of this RSS Feed (c) The Royal Society of Chemistry




ring

Random field reconstruction of three-phase polymer structures with anisotropy from 2D-small-angle scattering data

Soft Matter, 2024, 20,8493-8504
DOI: 10.1039/D4SM00721B, Paper
Open Access
Stephen Kronenberger, Nitant Gupta, Benjamin Gould, Colin Peterson, Arthi Jayaraman
We present a computational method to analyze 2D small-angle scattering data from three-phase soft materials systems with structural anisotropy and output representative real-space structures of the three phases.
The content of this RSS Feed (c) The Royal Society of Chemistry




ring

Rolling and ordering of micro rods in shear flow induced by rod wall interactions

Soft Matter, 2024, Advance Article
DOI: 10.1039/D4SM00999A, Paper
Open Access
  This article is licensed under a Creative Commons Attribution 3.0 Unported Licence.
Martin Wittmann, Igor M. Kulić, Antonio Stocco, Juliane Simmchen
We use experiments and theoretical models to investigate the rolling and translational motion of rod-shaped micro particles close to a solid wall in the presence or absence of shear flow.
To cite this article before page numbers are assigned, use the DOI form of citation above.
The content of this RSS Feed (c) The Royal Society of Chemistry




ring

Pickering emulsions for stimuli-responsive transdermal drug delivery: effect of rheology and microstructure on performance

Soft Matter, 2024, 20,8621-8637
DOI: 10.1039/D4SM00993B, Paper
Open Access
  This article is licensed under a Creative Commons Attribution 3.0 Unported Licence.
Simona Migliozzi, Yiting He, Maryam Parhizkar, Yang Lan, Panagiota Angeli
Elucidating the impact of microgels attributes on the microstructure, rheology and functionality of Pickering emulsions.
The content of this RSS Feed (c) The Royal Society of Chemistry




ring

Influence of counterion type on the scattering of a semiflexible polyelectrolyte

Soft Matter, 2024, 20,8610-8620
DOI: 10.1039/D4SM00874J, Paper
Open Access
Anish Gulati, Jack F. Douglas, Olga Matsarskaia, Carlos G. Lopez
Understanding the influence of counterion and backbone solvation on the conformational and thermodynamic properties of polyelectrolytes in solution is one of the main open challenges in polyelectrolyte science.
The content of this RSS Feed (c) The Royal Society of Chemistry




ring

Light scattering study of algal floc growth and structure: alum vs. polymeric plant-derived flocculant

Soft Matter, 2024, Advance Article
DOI: 10.1039/D4SM00837E, Paper
Temitope Orimolade, Ngoc-Tram Le, Lyle Trimble, Bandaru Ramarao, Sitaraman Krishnan
Algal flocculation using alum shows dynamic fractal restructuring over time, while Moringa oleifera protein induces faster densification, enhancing floc strength.
To cite this article before page numbers are assigned, use the DOI form of citation above.
The content of this RSS Feed (c) The Royal Society of Chemistry




ring

Thin free-standing liquid films manipulation: device design to turn on/off gravity in flow regimes for thickness map control and for material structuring

Soft Matter, 2024, Advance Article
DOI: 10.1039/D4SM00951G, Paper
Open Access
  This article is licensed under a Creative Commons Attribution 3.0 Unported Licence.
Paolo Iaccarino, Zhe Wang, Andrea Marfuggi, Simone Russo, Vincenzo Ferraro, Giuseppe Vitiello, Sara Coppola, Ernesto Di Maio
We design a device to control liquid film drainage, able to switch between viscous-capillary and viscous-gravity regimes to stabilize thickness and modify particle arrangement, offering potential for film studies and 2D structure fabrication.
To cite this article before page numbers are assigned, use the DOI form of citation above.
The content of this RSS Feed (c) The Royal Society of Chemistry




ring

Ring-shaped nanoparticle assembly and cross-linking on lipid vesicle scaffolds

Soft Matter, 2024, Advance Article
DOI: 10.1039/D4SM01010H, Communication
Open Access
  This article is licensed under a Creative Commons Attribution 3.0 Unported Licence.
Gizem Karabiyik, Aldo Jesorka, Irep Gözen
We show the assembly and cross-linking of carboxylate-modified polystyrene nanoparticles into flexible circular, ring-shaped structures with micrometer sized diameters around the base of surface-adhered giant lipid vesicles.
To cite this article before page numbers are assigned, use the DOI form of citation above.
The content of this RSS Feed (c) The Royal Society of Chemistry




ring

Pairing-specific microstructure in depletion gels of bidisperse colloids

Soft Matter, 2024, Advance Article
DOI: 10.1039/D4SM00811A, Paper
Open Access
Rony A. Waheibi, Lilian C. Hsiao
We report the ensemble-averaged and pairing-specific network microstructure formed by short-range depletion attractions in bidisperse hard sphere-like colloidal systems.
To cite this article before page numbers are assigned, use the DOI form of citation above.
The content of this RSS Feed (c) The Royal Society of Chemistry




ring

Five Interesting Ways to Use Array.reduce() (And One Boring Way)

Chris Ferdinandi turns the heat down low and lets the sauce reduce while we take a look at how to add spice to our source with a sprinkling of Array.reduce(). Just a little ingenuity with the humblest of functions.


Of all the modern array methods, the one I had the hardest time wrapping my head around was Array.reduce().

On the surface, it seems like a simple, boring method that doesn’t do much. But below its humble exterior, Array.reduce() is actually a powerful, flexible addition to your developer toolkit.

Today, we’re going to look at some cool things you can do with Array.reduce().

How Array.reduce() works

Most of the modern array methods return a new array. The Array.reduce() method is a bit more flexible. It can return anything. Its purpose is to take an array and condense its content into a single value.

That value can be a number, a string, or even an object or new array. That’s the part that’s always tripped me up – I didn’t realize just how flexible it is!

The syntax

The Array.reduce() accepts two arguments: a callback method to run against each item in the array, and a starting value.

The callback also accepts two arguments: the accumulator, which is the current combined value, and the current item in the loop. Whatever you return is used as the accumulator for the next item in the loop. On the very first loop, that starting value is used instead.

var myNewArray = [].reduce(function (accumulator, current) {
  return accumulator;
}, starting);

Let’s look at some examples to make this all tangible.

1. Adding numbers together

Let’s say you had an array of numbers that you wanted to add together. Using Array.forEach(), you might do something like this:

var total = 0;

[1, 2, 3].forEach(function (num) {
  total += num;
});

This is the cliche example for using Array.reduce(). I find the word accumulator confusing, so in this example, I’m calling it sum, because that’s what it is.

var total = [1, 2, 3].reduce(function (sum, current) {
  return sum + current;
}, 0);

Here, we pass in 0 as our starting value.

In the callback, we add the current value to the sum, which has our starting value of 0 on the first loop, then 1 (the starting value of 0 plus the item value of 1), then 3 (the sum value of 1 plus the item value of 2), and so on.

Here’s a demo.

2. Combining multiple array methods into Array.map() and Array.filter() into a single step

Imagine you had an array of wizards at Hogwarts.

var wizards = [
  {
    name: 'Harry Potter',
    house: 'Gryfindor'
  },
  {
    name: 'Cedric Diggory',
    house: 'Hufflepuff'
  },
  {
    name: 'Tonks',
    house: 'Hufflepuff'
  },
  {
    name: 'Ronald Weasley',
    house: 'Gryfindor'
  },
  {
    name: 'Hermione Granger',
    house: 'Gryfindor'
  }
];

You want to create a new array that contains just the names of wizards who are in Hufflepuff. One way you could do that is by using the Array.filter() method to get back just wizards whose house property is Hufflepuff. Then, you’d use the Array.map() method to create a new array containing just the name property for the remaining wizards.

// Get the names of the wizards in Hufflepuff
var hufflepuff = wizards.filter(function (wizard) {
  return wizard.house === 'Hufflepuff';
}).map(function (wizard) {
  return wizard.name;
});

With the Array.reduce() method, we can get the same array in a single pass, improving our performance. You pass in an empty array ([]) as the starting value. On each pass, you check to see if the wizard.house is Hufflepuff. If it is, you push it to the newArr (our accumulator in this example). If not, you do nothing.

Either way, you return the newArr to become the accumulator on the next pass.

// Get the names of the wizards in Hufflepuff
var hufflepuff = wizards.reduce(function (newArr, wizard) {
  if (wizard.house === 'Hufflepuff') {
    newArr.push(wizard.name);
  }
  return newArr;
}, []);

Here’s another demo.

3. Creating markup from an array

What if, instead of creating an array of names, we wanted to create an unordered list of wizards in Hufflepuff? Instead of passing an empty array into Array.reduce() as our starting value, we’ll pass in an empty string ('') and call it html.

If the wizard.house equals Hufflepuff, we’ll concatenate our html string with the wizard.name wrapped in an opening and closing list item (li). Then, we’ll return the html to become the accumulator on the next loop.

// Create a list of wizards in Hufflepuff
var hufflepuffList = wizards.reduce(function (html, wizard) {
  if (wizard.house === 'Hufflepuff') {
    html += '<li>' + wizard.name + '</li>';
  }
  return html;
}, '');

Add an opening and closing unordered list element before and after Array.reduce(), and you’re ready to inject your markup string into the DOM.

// Create a list of wizards in Hufflepuff
var hufflepuffList = '<ul>' + wizards.reduce(function (html, wizard) {
  if (wizard.house === 'Hufflepuff') {
    html += '<li>' + wizard.name + '</li>';
  }
  return html;
}, '') + '</ul>';

See it in action here.

4. Grouping similar items in an array together

The lodash library has a groupBy() method takes a collection of items as an array and groups them together into an object based on some criteria.

Let’s say you want an array of numbers.

If you wanted to group all of the items in numbers together based on their integer value, you would do this with lodash.

var numbers = [6.1, 4.2, 6.3];

// returns {'4': [4.2], '6': [6.1, 6.3]}
_.groupBy(numbers, Math.floor);

If you had an array of words, and you wanted to group the items in words by their length, you would do this.

var words = ['one', 'two', 'three'];

// returns {'3': ['one', 'two'], '5': ['three']}
_.groupBy(words, 'length');

Creating a groupBy() function with Array.reduce()

You can recreate that same functionality using the Array.reduce() method.

We’ll create a helper function, groupBy(), that accepts the array and criteria to sort by as arguments. Inside groupBy(), we’ll run Array.reduce() on our array, passing in an empty object ({}) as our starting point, and return the result.

var groupBy = function (arr, criteria) {
  return arr.reduce(function (obj, item) {
    // Some code will go here...
  }, {});
};

Inside the Array.reduce() callback function, we’ll check to see if the criteria is a function, or a property of the item. Then we’ll get its value from the current item.

If there’s no property in the obj with that value yet, we’ll create it and assign an empty array as its value. Finally, we’ll push the item to that key, and return the object as the accumulator for the next loop.

var groupBy = function (arr, criteria) {
  return arr.reduce(function (obj, item) {

    // Check if the criteria is a function to run on the item or a property of it
    var key = typeof criteria === 'function' ? criteria(item) : item[criteria];

    // If the key doesn't exist yet, create it
    if (!obj.hasOwnProperty(key)) {
      obj[key] = [];
    }

    // Push the value to the object
    obj[key].push(item);

    // Return the object to the next item in the loop
    return obj;

  }, {});
};

Here’s a demo of the completed helper function.

Special thanks to Tom Bremer for helping me make some improvements to this one. You can find this helper function and more like it on the Vanilla JS Toolkit.

5. Combining data from two sources into an array

Remember our array of wizards?

var wizards = [
  {
    name: 'Harry Potter',
    house: 'Gryfindor'
  },
  {
    name: 'Cedric Diggory',
    house: 'Hufflepuff'
  },
  {
    name: 'Tonks',
    house: 'Hufflepuff'
  },
  {
    name: 'Ronald Weasley',
    house: 'Gryfindor'
  },
  {
    name: 'Hermione Granger',
    house: 'Gryfindor'
  }
];

What if you had another data set, an object of house points each wizard has earned.

var points = {
  HarryPotter: 500,
  CedricDiggory: 750,
  RonaldWeasley: 100,
  HermioneGranger: 1270
};

Imagine you wanted to combine both sets of data into a single array, with the number of points added to each wizard’s data in the wizards array. How would you do it?

The Array.reduce() method is perfect for this!

var wizardsWithPoints = wizards.reduce(function (arr, wizard) {

  // Get the key for the points object by removing spaces from the wizard's name
  var key = wizard.name.replace(' ', '');

  // If the wizard has points, add them
  // Otherwise, set them to 0
  if (points[key]) {
    wizard.points = points[key];
  } else {
    wizard.points = 0;
  }

  // Push the wizard object to the new array
  arr.push(wizard);

  // Return the array
  return arr;

}, []);

Here’s a demo combining data from two sources into an array.

6. Combining data from two sources into an object

What if you instead wanted to combine the two data sources into an object, where each wizard’s name was the key, and their house and points were properties? Again, the Array.reduce() method is perfect for this.

var wizardsAsAnObject = wizards.reduce(function (obj, wizard) {

  // Get the key for the points object by removing spaces from the wizard's name
  var key = wizard.name.replace(' ', '');

  // If the wizard has points, add them
  // Otherwise, set them to 0
  if (points[key]) {
    wizard.points = points[key];
  } else {
    wizard.points = 0;
  }

  // Remove the name property
  delete wizard.name;

  // Add wizard data to the new object
  obj[key] = wizard;

  // Return the array
  return obj;

}, {});

Here’s a demo combining two data sets into an object.

Should you use Array.reduce() more?

The Array.reduce() method has gone from being something I thought was pointless to my favorite JavaScript method. So, should you use it? And when?

The Array.reduce() method has fantastic browser support. It works in all modern browsers, and IE9 and above. It’s been supported in mobile browsers for a long time, too. If you need to go back even further than that, you can add a polyfill to push support back to IE6.

The biggest complaint you can make about Array.reduce() is that it’s confusing for people who have never encountered it before. Combining Array.filter() with Array.map() is slower to run and involves extra steps, but it’s easier to read. It’s obvious from the names of the methods what they’re supposed to be doing.

That said, there are times where Array.reduce() makes things that would be complicated more simple rather than more complicated. The groupBy() helper function is a good example.

Ultimately, this is another tool to add to your toolkit. A tool that, if used right, can give you super powers.


About the author

Chris Ferdinandi helps people learn vanilla JavaScript. He believes there’s a simpler, more resilient way to make things for the web.

Chris is the author of the Vanilla JS Pocket Guide series, creator of the Vanilla JS Academy training program, and host of the Vanilla JS Podcast. His developer tips newsletter is read by thousands of developers each weekday.

He’s taught developers at organizations like Chobani and the Boston Globe, and his JavaScript plugins have been used used by Apple and Harvard Business School. Chris Coyier, the founder of CSS-Tricks and CodePen, has described his writing as “infinitely quote-worthy.”

Chris loves pirates, puppies, and Pixar movies, and lives near horse farms in rural Massachusetts. He runs Go Make Things with Bailey Puppy, a lab-mix from Tennessee.

More articles by Chris




ring

Bring home the medals

Fashion designer Ritu Beri wonders if privatisation is the key to India performing better at global sporting events




ring

String theory

Vidhya Maghanath Sunder designed jewellery as a hobby, but the response she got for her creations convinced her to look at it as a serious business venture