forked from dreamapplehappy/hacking-with-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.html
35 lines (35 loc) · 1020 Bytes
/
demo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<iframe src="https://ghbtns.com/github-btn.html?user=dreamapplehappy&repo=hacking-with-javascript&type=star&count=true&size=large"
frameborder="0" scrolling="0" width="160px" height="30px"></iframe>
<script>
// var a = 1;
// var b = 2;
// function compare(a, b) {
// return a > b ? a: b;
// }
// console.log(new Date);
// console.log(compare(a, b));
// console.log(new Date);
// console.log(new Date);
// console.log(a ^ ( (a ^ b) & -(a < b) ));
// console.log(new Date);
var a = 1;
var b = 2;
function compare(a, b) {
return a > b ? a : b;
}
console.time('use func');
console.log(compare(a, b));
console.timeEnd('use func');
console.time('use bitwise operators');
console.log(a ^ ( (a ^ b) & -(a < b) ));
console.timeEnd('use bitwise operators');
</script>
</body>
</html>