Skip to content

Instantly share code, notes, and snippets.

@leostaples
Created June 15, 2020 07:47
Show Gist options
  • Save leostaples/1b48e92cc220666e19fbe0a52279e257 to your computer and use it in GitHub Desktop.
Save leostaples/1b48e92cc220666e19fbe0a52279e257 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/kaweqoqore
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
function isLooselyEqual(left, right) {
return left === right || (!left && !right);
}
function passportsEqual(left, right) {
return (
isLooselyEqual(left.home, right.home) &&
isLooselyEqual(left.language, right.language) &&
isLooselyEqual(left.genre, right.genre) &&
isLooselyEqual(left.locator, right.locator)
);
}
const left = {
home: 'a',
language: 'b',
locator: 'foo',
}
const right = {
home: 'a',
language: 'b',
genre: null,
locator: 'foo',
}
console.log(passportsEqual(left, right) );
</script>
<script id="jsbin-source-javascript" type="text/javascript">function isLooselyEqual(left, right) {
return left === right || (!left && !right);
}
function passportsEqual(left, right) {
return (
isLooselyEqual(left.home, right.home) &&
isLooselyEqual(left.language, right.language) &&
isLooselyEqual(left.genre, right.genre) &&
isLooselyEqual(left.locator, right.locator)
);
}
const left = {
home: 'a',
language: 'b',
locator: 'foo',
}
const right = {
home: 'a',
language: 'b',
genre: null,
locator: 'foo',
}
console.log(passportsEqual(left, right) );
</script></body>
</html>
function isLooselyEqual(left, right) {
return left === right || (!left && !right);
}
function passportsEqual(left, right) {
return (
isLooselyEqual(left.home, right.home) &&
isLooselyEqual(left.language, right.language) &&
isLooselyEqual(left.genre, right.genre) &&
isLooselyEqual(left.locator, right.locator)
);
}
const left = {
home: 'a',
language: 'b',
locator: 'foo',
}
const right = {
home: 'a',
language: 'b',
genre: null,
locator: 'foo',
}
console.log(passportsEqual(left, right) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment