我有三页使用同一代码,有一页有这一变量,另两页有变票。 类型值为1或2。 我需要首先检查是否存在机票券、没有界定的票价以及第二需要确定是否为一票或二票。
如果说明产生错误:
if(typeof ticketType != undefined && ticketType == 1){}
它说的是ticket Type isn t下定义
。 如果说话是为了先考虑一下,那是 t,如果说话,但火焰火力仍然产生or,那么我就把话推到che。
任何想法? 必须找到办法......
我有三页使用同一代码,有一页有这一变量,另两页有变票。 类型值为1或2。 我需要首先检查是否存在机票券、没有界定的票价以及第二需要确定是否为一票或二票。
如果说明产生错误:
if(typeof ticketType != undefined && ticketType == 1){}
它说的是ticket Type isn t下定义
。 如果说话是为了先考虑一下,那是 t,如果说话,但火焰火力仍然产生or,那么我就把话推到che。
任何想法? 必须找到办法......
<>代码>未定义的在使用<>代码/代码>时,须在上面引用。
if(typeof ticketType != undefined && ticketType == 1){}
undefined should be within quotes...
if (typeof ticketType !== "undefined" && ticketType == 1)
{
}
http://www.ohchr.org。
在这里,我们不谈论global.un Defin。 不必在引文内附上。 我们谈论的是。 这是一种扼杀。 顺便提一下,回归类型“未界定”,因此,我们需要在扼杀中附上。
// ticketType is not defined yet
(typeof ticketType !== undefined) // This is true
(typeof ticketType === undefined) // This is false
(typeof ticketType !== "undefined") // This is false
(typeof ticketType === "undefined") // This is true
var ticketType = "someValue"; // ticketType is defined
(typeof ticketType !== undefined) // This is still true
(typeof ticketType === undefined) // This is still false
(typeof ticketType !== "undefined") // This is true
(typeof ticketType === "undefined") // This is false
因此,正确的核对对照是<代码>未定义的而不是global.un defined
。
Wrap it in parenthesis.
if (typeof (ticketType)!= 未加界定和计划; 类型==1
错误信息相当清楚。 为此:
var ticketType;
if(typeof ticketType != undefined && ticketType == 1){}
我们不能仅仅提及不存在的变量。 只有在指派以下人员时,你才能这样做:
ticketType = 1;
浏览器投诉,因为<代码>tuketType是一个不为人知的识别符号。 然而,如果我们首先宣布(即使没有分配任何价值),它就会为人所知,而是以<代码>未界定的数值表示。
if(typeof ticketType != undefined && ticketType == 1){}
我认为,你需要围绕未界定的字句。 至少我总是这样做。
你对未界定的变数进行不正确的核对,但如果你重新规划如何使用,为什么不仅确保加以界定?
ticketType = ticketType || 1;
if (ticketType === 1) {
//do stuff
}
正如其他人所显示的那样,在联合材料中,检查未界定价值的标准方法是:
typeof somevar === undefined
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.