Javascript- object slice

const foo = {
one: 'ONE',
two: 'TWO',
three: 'THRE',
four: 'FOUR',
}

const sliced = Object.fromEntries(
Object.entries(foo).slice(1, 3)
)

console.log(sliced)

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Tiles | Generative Art Tutorial

Can functional programming not be as weird?

Angular 10/9 CSS Flex Layout By Example

How To Use Svelte With Electron And TypeScript

Accelerating Node.js JavaScript for Visualization and Beyond with RAPIDS on GPUs

NGX-DataTable angular

Conditional Gating Component for React Rendering

Rollup vs. Parcel vs. Webpack: Which is the Best Bundler?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
blossom0417

blossom0417

More from Medium

all about javascript Promises

Introduction to JavaScript

Reverse an Array in JavaScript

Event Loop in JavaScript