在Firebug的控制台中
var a = [];
a[0] = a;
Run Code Online (Sandbox Code Playgroud)
崩溃的火狐!
为什么?
编辑:
编辑2:它在Firebug控制台崩溃,并在本机Firefox Web控制台中工作
注意:我对angularjs很新
什么是问题的最佳解决方案/实践:我有一个数组或类型值,每种类型应该有不同的输入(模板和输入验证)?
例如并简化
var vars = [
{
type: 'int',
value: 42,
min: 0,
max: 42
},
{
type: 'text',
value: 'foobar'
},
]
Run Code Online (Sandbox Code Playgroud)
'int'模板将是
<input type="range" max="{{max}}" min="{{min}}" value="{{value}}" />
Run Code Online (Sandbox Code Playgroud)
并为'文本'
<textarea>{{value}}</textarea>
Run Code Online (Sandbox Code Playgroud)
在实际情况中,会有很多具有奇怪接口的输入
我在VisualStudio2010中玩c ++
请解释IT发生的原因:
int a, b;
int *p, *q;
cout << a << " " << b;
Run Code Online (Sandbox Code Playgroud)
打印出"0 0".嗯,这是可以理解的,未初始化的整数应为0; 但
int a, b;
int *p, *q;
p = &a;
cout << a << " " << b;
Run Code Online (Sandbox Code Playgroud)
输出为"1792816880 0"
因此,如果我将指针指定给未初始化的变量,则会更改默认值.为什么?
编辑澄清:问题不是关于未初始化变量的值
int a; int *p;
cout << a; // would be 0, because it's loacal variable
p = &a;
cout << a; //not 0;
Run Code Online (Sandbox Code Playgroud)
如何获得的指针一个可以改变它的价值?当我们初始化变量时,我们分配空间,一些位,它们可以是任何东西,但"p =&a"它实际上是否改变了这个空间中的位?
我有课
function Foo(a) {
this.a = a;
this.bar = function () {
console.log(this.a);
};
this.buz = function () {
this.a();
console.log('bzz');
};
}
Run Code Online (Sandbox Code Playgroud)
我会有很多这类课程.我应该将方法移动到原型吗?
function Foo(a) {
this.a = a;
}
Foo.prototype = {
bar: function () {
console.log(this.a);
},
buz: function () {
this.a();
console.log('bzz');
}
}
Run Code Online (Sandbox Code Playgroud) 它不是关于 eval()
假设我有#password输入,我将此数据作为JSON对象的一部分发送
var toSend = {
text: 'hello',
pass: $("#password").val()
};
Run Code Online (Sandbox Code Playgroud)
我需要验证输入吗?将", you: "are hacked"通信的另一面解释为单个字符串或空字符串和另一个属性?
编辑:在浏览器环境中什么都不会发生,但是如果JSON将作为纯文本通过互联网发送并再次解析?
javascript ×4
angularjs ×1
c++ ×1
crash ×1
firebug ×1
firefox ×1
json ×1
performance ×1
pointers ×1
prototype ×1