Created
March 28, 2015 00:31
-
-
Save tonydieu/74d2b572278464e3d6b1 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/xidezu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.5.0/lodash.min.js"></script> | |
<script id="jsbin-javascript"> | |
var a = { title: 'super mario', cat: 'gamespot', date: 222, tv: 'tv2'}; | |
var b = [{title: 'metal gear'}, {title: 'super mario', cat: 'gamespot'}, {title: 'super mario 1'}]; | |
function someFunction() { | |
for (var i = 0; i < b.length; i++) { | |
var d = _.difference(_.values(_.omit(a, 'date', 'tv')), _.values(b[i])); | |
if(d.length === 0) { | |
// Found a duplicate | |
console.log('duplicate'); | |
break; | |
} | |
if (i === b.length - 1) { | |
// Did not find a copy | |
//insert | |
console.log('insert'); | |
} | |
} | |
} | |
var t0 = performance.now(); | |
someFunction(); | |
var t1 = performance.now(); | |
console.log("Call to doSomething took " + (t1 - t0) + " milliseconds."); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var a = { title: 'super mario', cat: 'gamespot', date: 222, tv: 'tv2'}; | |
var b = [{title: 'metal gear'}, {title: 'super mario', cat: 'gamespot'}, {title: 'super mario 1'}]; | |
function someFunction() { | |
for (var i = 0; i < b.length; i++) { | |
var d = _.difference(_.values(_.omit(a, 'date', 'tv')), _.values(b[i])); | |
if(d.length === 0) { | |
// Found a duplicate | |
console.log('duplicate'); | |
break; | |
} | |
if (i === b.length - 1) { | |
// Did not find a copy | |
//insert | |
console.log('insert'); | |
} | |
} | |
} | |
var t0 = performance.now(); | |
someFunction(); | |
var t1 = performance.now(); | |
console.log("Call to doSomething took " + (t1 - t0) + " milliseconds."); | |
</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = { title: 'super mario', cat: 'gamespot', date: 222, tv: 'tv2'}; | |
var b = [{title: 'metal gear'}, {title: 'super mario', cat: 'gamespot'}, {title: 'super mario 1'}]; | |
function someFunction() { | |
for (var i = 0; i < b.length; i++) { | |
var d = _.difference(_.values(_.omit(a, 'date', 'tv')), _.values(b[i])); | |
if(d.length === 0) { | |
// Found a duplicate | |
console.log('duplicate'); | |
break; | |
} | |
if (i === b.length - 1) { | |
// Did not find a copy | |
//insert | |
console.log('insert'); | |
} | |
} | |
} | |
var t0 = performance.now(); | |
someFunction(); | |
var t1 = performance.now(); | |
console.log("Call to doSomething took " + (t1 - t0) + " milliseconds."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment