Advertisements

Advertisements

"juglesh" <> writes:
> "$string = isset($xyz) ? $xyz : "something else";"
>
> Hello, someone gave code like this in another thread. I understand (by
> inference) what it does, but have not found any documentation on this
> type of syntax.
>
> Any one have links to this shortuct(?) syntax and other types of
> syntax?

juglesh wrote:
> "$string = isset($xyz) ? $xyz : "something else";"
>
> Hello, someone gave code like this in another thread. I understand (by
> inference) what it does, but have not found any documentation on this
> type of syntax.
>
> Any one have links to this shortuct(?) syntax and other types of
> syntax?
>
> thanks
> j
>

Except that in javascript - typeof - is an operator so its operand does
not need to be parenthesised. Though doing so is harmless, it is just
potentially misleading as to the nature of - typeof - because the
results resemble a function call.

which it has in common with PHP (where NULL is the sole value of
the NULL type), it yields

var x = null;
alert(typeof x); // `object'

This is most certainly an attribution to the fact that a reference
always refers to an object or not.

Conclusion:

Besides risking a ReferenceError (and hopefully catching it with exception
handling), there is no way in JS to determine whether a variable/property
was defined or not; it is only possible to determine whether it yields
`undefined' (the sole value of the internal Undefined type) or `null', or
not.

PointedEars
--
When the power of love overcomes the love
of power, the world will know peace.
-- Jimi Hendrix

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!