Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

comparing oblects

function isEqual(firstObj, secondObj) {
   const  firstKeys = Object.keys(firstObj);
  const  secondKeys  = Object.keys(secondObj);
  
  if(firstKeys.length !== secondKeys.length){
    return false;
  }
  
  return firstKeys.every(function (key) {
    return firstObj[key] === secondObj[key];
  })
}

const first = {
  property: "value",
  anotherProperty: "another value"
};

const second = {
  property: "value",
  anotherProperty: "another value"
};

const third = {
  property: "value",
  anotherProperty: "yet another value"
};

isEqual(first, second); // true
isEqual(second, third); // false
Comment

PREVIOUS NEXT
Code Example
Javascript :: multiple comparison javascript 
Javascript :: Access the list of valid values for an Enum field in a MongoDb Mongoose Schema 
Javascript :: Adding Handlers to All Forms 
Javascript :: full screen window open and disable all apps by javascript 
Javascript :: javascript centuries 
Javascript :: angular pass template value from component 
Javascript :: react rative release 
Javascript :: Logical Assignment Operator null coalescing 
Javascript :: js invert array 
Javascript :: how to change cursor color in vscode 
Javascript :: how to get html paramater in js 
Javascript :: js array take a elemt to front 
Javascript :: load widget after read data from json file 
Javascript :: linux pupperteer 
Javascript :: apollo client with functional component 
Javascript :: Sending e-mail using Mandrill API 
Javascript :: how to merge data rn 
Javascript :: find longest even string in array javascript 
Javascript :: como tanformar um paraafrafo para maiusculaavascript 
Javascript :: “javascript sleep 1 second” is a pretty common code problem that people search ;-) 
Javascript :: ajax status update switch toggle 
Javascript :: change class on resize window jquery 
Javascript :: typeorm caching queries time limit by id 
Javascript :: req.parms en react js 
Javascript :: multiplicar celulas js 
Javascript :: Example of Nullish coalescing assignment operator in es12 
Javascript :: hide modal event listener js 
Javascript :: A Note about Floats 
Javascript :: react native helper packages 
Javascript :: icon with label in react native 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =