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

JavaScript

 
QuestionWhat is the difference between compile and link function in angularjs ? Pin
protekconsulting4-Aug-15 19:04
protekconsulting4-Aug-15 19:04 
AnswerRe: What is the difference between compile and link function in angularjs ? Pin
Richard MacCutchan4-Aug-15 22:23
mveRichard MacCutchan4-Aug-15 22:23 
AnswerRe: What is the difference between compile and link function in angularjs ? Pin
Mukesh Pr@sad5-Aug-15 23:42
professionalMukesh Pr@sad5-Aug-15 23:42 
QuestionJson Restriction while posting large data through ajax Pin
Member 116922503-Aug-15 0:24
Member 116922503-Aug-15 0:24 
AnswerRe: Json Restriction while posting large data through ajax Pin
Kornfeld Eliyahu Peter4-Aug-15 20:52
professionalKornfeld Eliyahu Peter4-Aug-15 20:52 
GeneralRe: Json Restriction while posting large data through ajax Pin
Member 116922504-Aug-15 21:11
Member 116922504-Aug-15 21:11 
AnswerRe: Json Restriction while posting large data through ajax Pin
Kornfeld Eliyahu Peter4-Aug-15 21:14
professionalKornfeld Eliyahu Peter4-Aug-15 21:14 
General'undefined' is a flaw in JavaScript Pin
le_top1-Aug-15 0:17
le_top1-Aug-15 0:17 
I now consider that the way that 'undefined' is implemented in JavaScript represents a flaw in the language.

IMHO, everything (at least variables) in JavaScript are Objects, but I just realize that variables that are 'undefined', are not.
It is unfortunate that constant values are not objects. It would be a nice to have. For instance, it is possible to do:
JavaScript
var a=1; a.toString();
and not
JavaScript
1.toString();
.

With regards to undefined, it isn't possible to do neither
JavaScript
var a=undefined; a.toString();
nor
JavaScript
undefined.toString();


Hence it breaks several principles that Programming Languages should respect.

If 'undefined' were an object, it could act as a Null Object, and all variables would automatically have a
Null Object.

It would then suffice to do something like:
JavaScript
Object.prototype.isMyObject=false;
MyObject.prototype.isMyObject=true;

and then one could always write:
if(anyvar.isMyObject){ /*...*/ }

without falling in the undefined issue.

However, I do understand that today many developers may partly rely on 'undefined' resulting in an exception to detect flaws in their programs. Therefore a new option might be added to JavaScript, much like "strict" in order to indicate that 'undefined' should act as a Null Object. But that might not even be necessary, as the exception could simply be thrown only when trying to get a missing member of the object, as in:
JavaScript
undefined.missingVariable
or
JavaScript
undefined.missingFunction()
.

So in conclusion: having undefined variables behave as Objects would make the JavaScript language "more complete", and having constants (like the number 1) behave as Objects would take it even one step further.

If those impacting the definition of the language could consider that, I would be quite happy about it.
--
Mario DW


modified 1-Aug-15 8:23am.

GeneralRe: 'undefined' is a flaw in JavaScript Pin
Kornfeld Eliyahu Peter3-Aug-15 3:58
professionalKornfeld Eliyahu Peter3-Aug-15 3:58 
GeneralRe: 'undefined' is a flaw in JavaScript Pin
le_top3-Aug-15 4:54
le_top3-Aug-15 4:54 
AnswerRe: 'undefined' is a flaw in JavaScript Pin
Kornfeld Eliyahu Peter3-Aug-15 7:37
professionalKornfeld Eliyahu Peter3-Aug-15 7:37 
GeneralRe: 'undefined' is a flaw in JavaScript Pin
le_top3-Aug-15 8:09
le_top3-Aug-15 8:09 
AnswerRe: 'undefined' is a flaw in JavaScript Pin
Kornfeld Eliyahu Peter4-Aug-15 21:16
professionalKornfeld Eliyahu Peter4-Aug-15 21:16 
SuggestionRe: 'undefined' is a flaw in JavaScript Pin
camycentsolutions5-Aug-15 23:40
camycentsolutions5-Aug-15 23:40 
QuestionSimple Slideshow Pin
Alex Mander30-Jul-15 6:20
Alex Mander30-Jul-15 6:20 
QuestionJava Script Pin
jubayer30-Jul-15 3:15
jubayer30-Jul-15 3:15 
AnswerRe: Java Script Pin
Afzaal Ahmad Zeeshan30-Jul-15 4:07
professionalAfzaal Ahmad Zeeshan30-Jul-15 4:07 
QuestionIncrementing/Decrementing not by 1 Pin
Member 1184785029-Jul-15 19:14
Member 1184785029-Jul-15 19:14 
AnswerRe: Incrementing/Decrementing not by 1 Pin
Peter_in_278029-Jul-15 20:27
professionalPeter_in_278029-Jul-15 20:27 
QuestionOK, Javascript gurus, why is "if" not evaluating as true or false ? Pin
Marc Clifton28-Jul-15 15:19
mvaMarc Clifton28-Jul-15 15:19 
QuestionRe: OK, Javascript gurus, why is "if" not evaluating as true or false ? Pin
Richard Deeming29-Jul-15 1:50
mveRichard Deeming29-Jul-15 1:50 
AnswerRe: OK, Javascript gurus, why is "if" not evaluating as true or false ? Pin
Marc Clifton29-Jul-15 4:39
mvaMarc Clifton29-Jul-15 4:39 
GeneralRe: OK, Javascript gurus, why is "if" not evaluating as true or false ? Pin
Richard Deeming29-Jul-15 4:47
mveRichard Deeming29-Jul-15 4:47 
GeneralRe: OK, Javascript gurus, why is "if" not evaluating as true or false ? Pin
Marc Clifton29-Jul-15 5:09
mvaMarc Clifton29-Jul-15 5:09 
AnswerRe: OK, Javascript gurus, why is "if" not evaluating as true or false ? Pin
Afzaal Ahmad Zeeshan29-Jul-15 5:20
professionalAfzaal Ahmad Zeeshan29-Jul-15 5:20 

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.