This project is archived and is in readonly mode.

#189 ✓invalid

$type and $defined don't return false on non-existing object/var as it should

Reported by Jabis | July 3rd, 2008 @ 09:51 AM | in 2.0 (closed)

I'm checking for some secret vars/objects' existence, as follows, on load/domready, but get blargh is not defined JS error with at least firefox.

in example: mysecretstuff is not defined

window.addEvent('load', function() {
  if(!$defined(mysecretstuff) || $type(mysecrestuff) === false) {
  else {

the oldschool way I get my result appropriately:

mysecretstuff = window.mysecretstuff ? window.mysecretstuff : false;
if(!mysecretstuff) {... }

Now the trick is, that the mysecretstuff.js is only included if certain things are true serverside, so the variable/object otherwise is intended to be undefined, but shouldn't $type and $defined check just that?

Comments and changes to this ticket

  • Jan Kassens

    Jan Kassens July 3rd, 2008 @ 04:10 PM

    • State changed from “new” to “invalid”

    no, its not possible with javascript, you need to use $defined( in the case of a global var.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket