Languages

What is the best way to compare two objects in javascript?

14 points
Asked by:
Marcin
2444

I whould like to compare two objects in javascript but it it doesn't work.

// ONLINE-RUNNER:browser;

var val_1 = {
  name: 'test',
  age: 25
};

var val_2 = {
  name: 'test',
  age: 25
};

console.log(val_1 == val_2)

What I am doing wrong?

0 answers
Hey 👋
Would you like to know what we do?
  • Dirask is a friendly IT community for learners, professionals and hobbyists to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.