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 f = function(...args) { | |
console.log(this.value, ...args); | |
}; | |
// 1 | |
var bindA = function(fn, that) { | |
var sF = f.toString().replace(/\n/g, ''); |
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 supportsPassive = false; | |
document.createElement("div").addEventListener("test", function() {}, { | |
get passive() { | |
supportsPassive = true; | |
return false; | |
} | |
}); |
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
(~~(Math.random() * (1 << 24) )).toString(16) |
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
function createRequest(uri) { | |
var client = new XMLHttpRequest(); | |
client.onreadystatechange = function() { | |
if(this.readyState == this.DONE) | |
if(this.status == 200 && this.responseText != null) { | |
return processData(this.responseText); | |
} | |
processData(null); | |
} | |
client.open("GET", uri); |
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
function Box () { | |
var animationStartTime = 0; | |
var animationDuration = 500; | |
var target = document.querySelector('.box'); | |
this.startAnimation = function() { | |
animationStartTime = Date.now(); | |
requestAnimationFrame(update); | |
}; |
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
/** flexbox parent and children style */ | |
.display-flexbox { | |
display: -webkit-box; | |
display: -webkit-flex; | |
display: flex; | |
} | |
.flexbox-children { | |
-webkit-box-flex: 1; | |
-webkit-flex: 1; |
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
// Create a new branch and fetch frome remote branch | |
$ git checkout -b hotfix origin/hotfix | |
// Create a branch based one commit | |
// Fix branch | |
$ git checkout -b hotfix 7bda10c6488835f4c54079cec78cc539a0c152c6 | |
$ git push origin hotfix | |
// Create a new branch hotfix based on master | |
$ git checkout -b hotfix master |
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 lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
<style> | |
.text-ellipsis-2 { | |
overflow: hidden; | |
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
function unique(array) { | |
return array.filter(function(entry, pos, entries) { | |
return entries.indexOf(entry) === pos; | |
}); | |
} |
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
function arraySum(array) { | |
var index, entry, sum = 0, len = array.length; | |
for(index = 0; index < len; index += 1){ | |
entry = array[index]; | |
sum += (entry instanceof Array) ? arraySum(entry) : ((typeof entry === 'number' && !isNaN(entry)) ? entry : 0); | |
} | |
return sum; |
NewerOlder