Code Snippets Flashcards

1
Q

How do you remove duplicates from an array?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you sort a numeric array?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you convert a string to a an array? 

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you reverse an array?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you break up a string where each word becomes an array entry?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can you deep clone an object in JavaScript? Provide an example.

A

const obj = { name: ‘John’, age: 30 };
const clonedObj = JSON.parse(JSON.stringify(obj));
console.log(clonedObj); // Output: { name: ‘John’, age: 30 }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly