Skip to main content
Arrow functions aren't exclusive to typescript; also added link to docs
Source Link
xyhhx
  • 6.7k
  • 6
  • 45
  • 67

Another functional solution in Typescriptusing arrow functions:

let el = document.querySelector('div'); let style = window.getComputedStyle(el); let height = ['height', 'padding-top', 'padding-bottom'] .map((key) => parseInt(style.getPropertyValue(key), 10)) .reduce((prev, cur) => prev + cur); 

Another functional solution in Typescript :

let el = document.querySelector('div'); let style = window.getComputedStyle(el); let height = ['height', 'padding-top', 'padding-bottom'] .map((key) => parseInt(style.getPropertyValue(key), 10)) .reduce((prev, cur) => prev + cur); 

Another functional solution using arrow functions:

let el = document.querySelector('div'); let style = window.getComputedStyle(el); let height = ['height', 'padding-top', 'padding-bottom'] .map((key) => parseInt(style.getPropertyValue(key), 10)) .reduce((prev, cur) => prev + cur); 
Source Link
EricD
  • 551
  • 6
  • 26

Another functional solution in Typescript :

let el = document.querySelector('div'); let style = window.getComputedStyle(el); let height = ['height', 'padding-top', 'padding-bottom'] .map((key) => parseInt(style.getPropertyValue(key), 10)) .reduce((prev, cur) => prev + cur);