我想使用gitk比较2个分支,而不是其他分支历史的混乱.
我可以通过gui实现这一点:查看>新视图>分支和标签:v0.8.x v0.9.x
我尝试了以下内容,但它仍然显示所有分支:gitk --branches v0.8.x v0.9.x
正确的语法是什么?
在Firefox中,以下两个函数之间似乎存在很大的性能差异:
var n1 = 12;
var add1 = function(n2){
return n1 + n2;
}
var add2 = (function(){
return function(n2){
return n1 + n2;
}
})();
Run Code Online (Sandbox Code Playgroud)
我认为这必须归结于另一个范围的引入,因此创建了第三个示例,其中变量缓存了一个级别.但这显示出更大的减少(80%!)
var add3 = (function(){
var cn1 = n1;
return function(n2){
return cn1 + n2;
}
})();
Run Code Online (Sandbox Code Playgroud)
我本以为这里的关闭将缩小性能差距,而不是扩大它.有没有人知道这里发生了什么?
jsPerf测试页:http://jsperf.com/variable-scope-speed
我经常在函数中有可选的参数,但是一些测试在firefox和safari中显示出巨大的性能影响(70-95%).奇怪的是,如果我传入未定义的文字值,那么就没有惩罚.这可能发生什么?我不会认为它是一个范围链问题,因为它们本身就是函数的本地.我是否开始将undefined传递给每个可选参数?
jsPerf:http://jsperf.com/function-undefined-args/2
从我的测试中可以看出,可以从DOM中删除脚本标记,而不会对其包含的JavaScript产生任何影响.
此测试通过执行部分破坏脚本DOM节点.即使这对脚本没有影响,count
也会在从DOM中删除脚本标记1
后为变量分配值.
<!DOCTYPE html>
<html lang="en">
<head>
<title> Test </title>
<script id="jQueryScriptTag" src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
</head>
<body>
<button id="testBtn">Click to test</button>
<div id="output"></div>
<script id="testCodeScriptTag">
var count;
$("#jQueryScriptTag").remove();
$("#testCodeScriptTag").remove();
$("#output").append(
"<p>jQueryScriptTag is " + document.getElementById("jQueryScriptTag") + "</p>" +
"<p>testCodeScriptTag is " + document.getElementById("testCodeScriptTag") + "</p>" +
"<p>count is " + count + "</p>"
);
count = 1;
$("#testBtn").click(function(){
$("#output").append(
"<p>count is " + (count++) + "</p>"
);
});
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
用例是从主机站点安全地删除注入的第三方脚本元素.
这不是一个错误,因为Win7上的FF,Chrome,IE9和Safari的行为是一致的.
我正在处理的应用程序是主机页面的第三方,因此CSS是不可变的.脚本尝试将新div与现有元素对齐.
这里的示例,JS被评论为复制每个案例:http:
//codepen.io/anon/pen/EGvlb
我不认为这是jQuery的错误 - 它似乎归结为H1边缘和body元素之间的合法关系?
$(function(){
/* Setting body to position:relative breaks offset()
because H1 margin moves body down */
$(document.body).css({position: "relative"});
/* Strange: putting a border on body fixes things? */
//$(document.body).css({border: "1px solid #000"});
/* Removing H1 margin removes problem */
//$("h1").css({margin: 0});
$("#overlay").css({
left: $("#existing").offset().left,
top: $("#existing").offset().top
})
});
Run Code Online (Sandbox Code Playgroud) The Elm docs illustrate type variables like this:
> List.reverse
<function> : List a -> List a
Run Code Online (Sandbox Code Playgroud)
...the type variable a can vary depending on how List.reverse is used. But in this case, we have an a in the argument and in the result. This means that if you give a List Int you must get a List Int as well.
The docs for Maybe.map show this annotation:
map : (a -> b) -> Maybe a -> Maybe b
Run Code Online (Sandbox Code Playgroud)
那么为什么这些类型被注释为 …
This interface is an example from the TypeScript docs.
The compiler shows an error for height
, even though it allows me to set it?
// Interface taken from https://www.typescriptlang.org/docs/handbook/interfaces.html
interface SquareConfig {
color?: string;
width?: number;
[propName: string]: any;
}
const sq = <SquareConfig>{
color: 'red',
width: 7890,
height: 888
}
console.log(sq.height); // Property 'height' does not exist on type 'SquareConfig'
Run Code Online (Sandbox Code Playgroud) 我在JS函数中发现了这个错误,其中一个url是一个注释,但斜杠被省略了......奇怪的是没有抛出JS错误?为什么以冒号结尾的行不会产生... is not defined
错误?
function test() {
https://www.test.com
console.log('success');
}
test();
Run Code Online (Sandbox Code Playgroud) javascript ×5
performance ×2
arguments ×1
css ×1
dom ×1
elm ×1
git ×1
gitk ×1
html ×1
jquery ×1
position ×1
scope ×1
types ×1
typescript ×1