90% Quick array question asked in javascript interview:

Q1.Find and return the specific element in the array:

const superHerosColors= [ { type: “IronMan”, color: “HotRed” }, { type: “Hulk”, color: “Green” } ];
getColor = superHerosColors.find((item) => item.color === “HotRed”);

console.log(getColor)

Ouput : { type: ‘IronMan’, color: ‘HotRed’ }

Q2. Reverse the array

var count = [1, 2, 3, 4, 5]

count.reverse()

console.log(count);

Output: [5, 4, 3, 2, 1]

Q3. Guess the output:

Object.is(‘foo’, ‘foo’)

Object.is(null, null)

Object.is(Nan, Nan)

const foo = { a: 1 }

const bar = { a: 1 }

Object.is(foo, foo)

Object.is(foo, bar)

Ouput:

Object.is(‘foo’, ‘foo’) // true

Object.is(null, null) // true

Object.is(Nan, Nan) // true

const foo = { a: 1 }

const bar = { a: 1 }

Object.is(foo, foo)// true

Object.is(foo, bar) // false

--

--

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
Vineet Mishra

Vineet Mishra

Full Stack Developer at CCR Tech, I write about Mobile/Web Development and Deployment, and Interview Q & A