This example describes the use of undefined variables or values in JavaScript. Share to everyone for your reference, specific as follows:
JavaScript generally cannot use undefined values, except for the following:
1. In the assignment statement:
A variable in an assignment statement that needs to be assigned is undefined and then assigned a value. In addition, you can see from the a=b=c=8 that the assignment statement is executed from right to left.
2. In statement:
For (key in {name: ' goofy '}) {
alert (key)//' name '
}
alert (key)//' name '
The variable in the to left of in statement will be defined first if not defined
3. After the TypeOf operator:
Alert (typeof a)//' undefined '
alert (a)//uncaught referenceerror:a is not defined
The typeof operator can be defined with an undefined value, but it is not actively defined
4. Object properties:
var o={name: ' Goofy '}
alert (o.name)//' goofy '
o[age]=24;//uncaught referenceerror:age are not defined
Alert (o.age)
When defining an object property, it is possible to use an undefined value in the form of a JSON direct amount, but an error is made if you use the subscript form.
5. Parameters of Function:
function fn (a,b) {
alert (a)//4
alert (b)//' undefined '
}
fn (4)
The function can be used to define the parameters actively, so the parameters of the function are directly available in the function body, and this parameter is not transmitted without error when the Instant method is invoked.
More readers interested in JavaScript-related content can view this site: "JavaScript in the JSON Operation tips Summary", "JavaScript switching effects and techniques summary", "JavaScript Search Algorithm Skills summary", " JavaScript animation effects and tips Summary, "JavaScript Error and debugging skills Summary", "JavaScript data structure and algorithm skills summary", "JavaScript traversal algorithm and Skills summary" and "JavaScript Mathematical operation Usage Summary"
I hope this article will help you with JavaScript programming.