如联合材料专题所述,好部分似乎声称财产价值可能没有界定。 但是,如果你在 Chrome的 con中做以下工作:
var foo = {}
foo.bar = undefined
foo
然后点击扩大 f物,你仍然可以看到, f含有一种被称作“ bar”但价值不明的财产。 当然,从贾瓦特一侧看,你可以说明 f与bar之间的区别。 但是,对于被确定为未界定的财产,这究竟是哪一个ole子?
如联合材料专题所述,好部分似乎声称财产价值可能没有界定。 但是,如果你在 Chrome的 con中做以下工作:
var foo = {}
foo.bar = undefined
foo
然后点击扩大 f物,你仍然可以看到, f含有一种被称作“ bar”但价值不明的财产。 当然,从贾瓦特一侧看,你可以说明 f与bar之间的区别。 但是,对于被确定为未界定的财产,这究竟是哪一个ole子?
<代码>un Defin is Javascript s way of informing You that a Value doesn t existence not在你在没有尝试/渔获区的情况下进入该财产时留下错误。 虽然从技术上看,Crockford的账户错失了 Chrome,但至少是合乎逻辑的;尽管该财产是“未界定的
。
当你想搬走财产时,你可使用>。
delete foo.bar;
现有和未界定的财产与未存在的财产之间有差别,因此 Chrome在这里是明智的。 如果你给财产分配价值,该财产就根本存在。 一种不同之处是,已明确确定为未界定的财产将载于<...in <>code>。
var foo = {};
foo.bar = undefined;
// The following will alert "bar"
for (var i in foo) {
alert(i);
}
另一种做法是,将<条码>条码>的“条令”退回<条形码><>true,并将<条码>。
从技术上讲,没有定义是分配变量的有效价值。 它的确发挥了作用,尽管通常并不有用:
var foo = {
bar: undefined
};
foo.hasOwnProperty("bar"); // returns true
foo.hasOwnProperty("bat"); // returns false
此外:
for (var n in foo) {
console.log(n, foo[n]); // should log "bar" and "undefined"
}
我个人将遵循Crockford在此案中的建议。 将<条码>定义为一种价值,可导致混淆代码,因此应视为无效。 它对人们不期望它感到惊讶。
我们已经有<代码>null用于这一目的,而这一条对未来维护者的混淆不大。 <代码>un Defin really mean not defined and use null
to mean not known.
请注意,在阅读Crockford书时,你根据他的说法,重读了有关最佳做法和意见的建议。 How javascript actual work is a different matter all (and给他说不一定是好的)。
How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.
I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...
Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...
Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...
I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...
Is it possible for someone to give me a few pointers on how to display a multidimensional array in the form of a bar graph? The array is multidimensional, with three elements in each part - and the ...
Is it possible to reload a form after file-input change? I have a form where the user can chose an image for upload. I also have a php script which displays that image resized. I only wonder if it ...
I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.