Click here to Skip to main content
15,902,840 members
Home / Discussions / JavaScript
   

JavaScript

 
Questionhow to enable/disable multiselection of table cells Pin
asbasir24-Jan-11 22:36
asbasir24-Jan-11 22:36 
Questionopener.document Pin
fififlowertot24-Jan-11 22:06
fififlowertot24-Jan-11 22:06 
AnswerRe: opener.document Pin
Richard MacCutchan25-Jan-11 3:03
mveRichard MacCutchan25-Jan-11 3:03 
AnswerRe: opener.document Pin
GenJerDan25-Jan-11 3:10
GenJerDan25-Jan-11 3:10 
QuestionChanging the CSS properties of a menu bar. Pin
Douglas Kirk24-Jan-11 20:56
Douglas Kirk24-Jan-11 20:56 
Questionvar abc = abc || {}; in Java Script Pin
Umair Feroze18-Jan-11 0:27
Umair Feroze18-Jan-11 0:27 
AnswerRe: var abc = abc || {}; in Java Script Pin
Umair Feroze19-Jan-11 3:12
Umair Feroze19-Jan-11 3:12 
GeneralRe: var abc = abc || {}; in Java Script Pin
jsc4219-Jan-11 5:53
professionaljsc4219-Jan-11 5:53 
Umair Feroze wrote:
It says if there is a class called ABC create a namespace of it, otherwise create a blank namespace.


No, it doesn't create a namespace, because JavaScript doesn't have namespaces; and it does not look for a class as JavaScript does not have classes.

It leaves abc as it is if it is an expression whose Boolean value is true e.g. is a non-zero value, a non-empty string, true, a function, or an object (including an array, even if empty). If it is not a true value, it replaces it with an empty object.

This is a common idion for defining a variable to hold a context (not a JavaScript concept) without accidentally overwriting it if it is already in use. It is better than simply doing var abc = { }; because any properties in the object will be retained.

Technically, it is bad JavaScript because var creates a variable. The appearance of it on the right hand side of an expression when defining it in the left hand side could (in theory) end up using it between the time it is defined and the time it is initialised.

I'd rather do ...
if (typeof abc != 'object') // Use existing abc if it is an object
   var abc = { }; // Create empty abc

although it is questionable as to whether this is valid or not as vars are 'hitched' so it is equivalent to
var abc; 
if (typeof abc != 'object')
   abc = { };

but you can get away with it because varing a variable that already exists in the current scope has no effect.
GeneralRe: var abc = abc || {}; in Java Script Pin
Not Active19-Jan-11 7:09
mentorNot Active19-Jan-11 7:09 
GeneralRe: var abc = abc || {}; in Java Script Pin
jsc4220-Jan-11 3:30
professionaljsc4220-Jan-11 3:30 
GeneralRe: var abc = abc || {}; in Java Script Pin
Not Active20-Jan-11 3:49
mentorNot Active20-Jan-11 3:49 
QuestionGet JSON Array [modified] Pin
dataminers17-Jan-11 12:04
dataminers17-Jan-11 12:04 
Questionzoom in and zoom out for entire page in all browser Pin
niladri0310-Jan-11 1:56
niladri0310-Jan-11 1:56 
AnswerRe: zoom in and zoom out for entire page in all browser Pin
J4amieC10-Jan-11 2:42
J4amieC10-Jan-11 2:42 
AnswerRe: zoom in and zoom out for entire page in all browser Pin
Not Active10-Jan-11 2:49
mentorNot Active10-Jan-11 2:49 
GeneralRe: zoom in and zoom out for entire page in all browser Pin
Ed Nutting14-Jan-11 9:03
Ed Nutting14-Jan-11 9:03 
GeneralRe: zoom in and zoom out for entire page in all browser Pin
Not Active14-Jan-11 9:23
mentorNot Active14-Jan-11 9:23 
GeneralRe: zoom in and zoom out for entire page in all browser Pin
Ed Nutting14-Jan-11 9:34
Ed Nutting14-Jan-11 9:34 
GeneralRe: zoom in and zoom out for entire page in all browser Pin
Not Active14-Jan-11 9:48
mentorNot Active14-Jan-11 9:48 
GeneralRe: zoom in and zoom out for entire page in all browser Pin
Ed Nutting14-Jan-11 9:57
Ed Nutting14-Jan-11 9:57 
Questionhow to gridivew in-place edit with jquery Pin
Tridip Bhattacharjee9-Jan-11 23:58
professionalTridip Bhattacharjee9-Jan-11 23:58 
AnswerRe: how to gridivew in-place edit with jquery Pin
Not Active10-Jan-11 2:46
mentorNot Active10-Jan-11 2:46 
Questionregarding Jquery Modal popup Pin
Tridip Bhattacharjee9-Jan-11 23:56
professionalTridip Bhattacharjee9-Jan-11 23:56 
AnswerRe: regarding Jquery Modal popup Pin
Not Active10-Jan-11 2:44
mentorNot Active10-Jan-11 2:44 
GeneralRe: regarding Jquery Modal popup Pin
marc lambert o. agas19-Jan-11 21:44
marc lambert o. agas19-Jan-11 21:44 

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.