Click here to Skip to main content
15,886,689 members
Home / Discussions / JavaScript
   

JavaScript

 
QuestionCondition Always true when checking for "undefined" in Javascript Pin
Vimalsoft(Pty) Ltd3-Aug-14 9:28
professionalVimalsoft(Pty) Ltd3-Aug-14 9:28 
AnswerRe: Condition Always true when checking for "undefined" in Javascript Pin
Blikkies3-Aug-14 22:48
professionalBlikkies3-Aug-14 22:48 
AnswerRe: Condition Always true when checking for "undefined" in Javascript Pin
Kornfeld Eliyahu Peter4-Aug-14 0:19
professionalKornfeld Eliyahu Peter4-Aug-14 0:19 
AnswerRe: Condition Always true when checking for "undefined" in Javascript Pin
Kornfeld Eliyahu Peter3-Aug-14 22:55
professionalKornfeld Eliyahu Peter3-Aug-14 22:55 
AnswerRe: Condition Always true when checking for "undefined" in Javascript Pin
Graham Breach3-Aug-14 22:56
Graham Breach3-Aug-14 22:56 
AnswerRe: Condition Always true when checking for "undefined" in Javascript Pin
Kornfeld Eliyahu Peter4-Aug-14 0:15
professionalKornfeld Eliyahu Peter4-Aug-14 0:15 
GeneralRe: Condition Always true when checking for "undefined" in Javascript Pin
Vimalsoft(Pty) Ltd4-Aug-14 5:39
professionalVimalsoft(Pty) Ltd4-Aug-14 5:39 
GeneralRe: Condition Always true when checking for "undefined" in Javascript Pin
Graham Breach4-Aug-14 9:18
Graham Breach4-Aug-14 9:18 
The typeof for an undefined value is always "undefined". The value undefined being in the global namespace opens up some possible problems:
JavaScript
function madness() {
  // override with local variable
  var a = 'fish', undefined = 'fish';

  if(a === undefined) {
    // both 'fish', so here we are
  }
}

function mistake() {
  var a = 'fish';

  // common mistake, using '=' instead of '=='
  if(undefined = a) {
    // 'undefined' is not a constant or keyword, so the whole 
    // expression is valid and will be true
  }
}

I know these are pretty unlikely scenarios, but better safe than sorry.

In earlier browsers "undefined" was not a testable value so expressions like (a == undefined) would produce the helpful message "undefined is undefined".
AnswerRe: Condition Always true when checking for "undefined" in Javascript Pin
Kornfeld Eliyahu Peter4-Aug-14 18:38
professionalKornfeld Eliyahu Peter4-Aug-14 18:38 
GeneralRe: Condition Always true when checking for "undefined" in Javascript Pin
Graham Breach4-Aug-14 22:13
Graham Breach4-Aug-14 22:13 
AnswerRe: Condition Always true when checking for "undefined" in Javascript Pin
Tushar Guru8-Sep-14 21:59
Tushar Guru8-Sep-14 21:59 
QuestionNewbie Question On jQuery Selectors Pin
Richard Andrew x641-Aug-14 17:03
professionalRichard Andrew x641-Aug-14 17:03 
AnswerRe: Newbie Question On jQuery Selectors Pin
thatraja1-Aug-14 18:09
professionalthatraja1-Aug-14 18:09 
GeneralRe: Newbie Question On jQuery Selectors Pin
Richard Andrew x641-Aug-14 18:28
professionalRichard Andrew x641-Aug-14 18:28 
QuestionGenerate geofence for route (pointA to pointB) Pin
JANANDOJAN28-Jul-14 21:19
JANANDOJAN28-Jul-14 21:19 
AnswerRe: Generate geofence for route (pointA to pointB) Pin
JANANDOJAN29-Jul-14 23:02
JANANDOJAN29-Jul-14 23:02 
GeneralRe: Generate geofence for route (pointA to pointB) Pin
Kwod128-Dec-20 11:01
Kwod128-Dec-20 11:01 
QuestionUsing json and jquery on page not working Pin
Member 1094998624-Jul-14 8:36
Member 1094998624-Jul-14 8:36 
QuestionRe: Using json and jquery on page not working Pin
ZurdoDev24-Jul-14 10:07
professionalZurdoDev24-Jul-14 10:07 
AnswerRe: Using json and jquery on page not working Pin
Member 1094998624-Jul-14 11:14
Member 1094998624-Jul-14 11:14 
QuestionRe: Using json and jquery on page not working Pin
ZurdoDev24-Jul-14 11:40
professionalZurdoDev24-Jul-14 11:40 
AnswerRe: Using json and jquery on page not working Pin
Member 1094998624-Jul-14 11:50
Member 1094998624-Jul-14 11:50 
Questiondisable a onclick function, and enable it Pin
jkirkerx18-Jul-14 12:24
professionaljkirkerx18-Jul-14 12:24 
AnswerRe: disable a onclick function, and enable it Pin
Dennis E White29-Jul-14 4:04
professionalDennis E White29-Jul-14 4:04 
GeneralRe: disable a onclick function, and enable it Pin
jkirkerx29-Jul-14 6:01
professionaljkirkerx29-Jul-14 6:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.