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

JavaScript Scope and Scope Chain

LeetCode 1810: Minimum Path Cost in a Hidden Grid

Everything You Need To Know About Face Changing App And How Much Will It Cost You?

Add YouTube player to flutter app

picoCTF: GET aHEAD

Migrating 2,000+ Specs from Karma to Jest

Nike Air Zoom Wildhorse 3 GTX https://t.co/PPFr8sFDEx https://t.co/15MpoQO3Qt

The Linked List Data Structure

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

Fun with Promises in Javascript

padEnd() JavaScript

ES6 JavaScript

How to get all previous items of an array in js from a certain value