0

var a,b,c,d; b=a; c=a+b; d=c-a; alert(d==b);

//output= false //do u have any explanation?

24th Jun 2017, 4:05 PM
islam moheb
islam moheb - avatar
7 Answers
+ 1
you didn't assign any value. so NaN != undefined
24th Jun 2017, 5:35 PM
Da' BO$
Da' BO$ - avatar
0
Elie! why have assigned d to 2??
24th Jun 2017, 6:13 PM
islam moheb
islam moheb - avatar
0
the coding missing numbers, it give undefined if there's no numbers...i gived you example with numbers
24th Jun 2017, 6:16 PM
Elie Douaihy
Elie Douaihy - avatar
0
ok, I mean the example is wrong
24th Jun 2017, 6:17 PM
islam moheb
islam moheb - avatar
0
yep to get false you need to assign a number to var a b c d
24th Jun 2017, 6:32 PM
Elie Douaihy
Elie Douaihy - avatar
0
best practice is to declare each variable separate, not all ina single line. then assign each variable immediately a value, request memory resources and initialization go should go in one step if possible.
24th Jun 2017, 9:11 PM
Volker Milbrandt
Volker Milbrandt - avatar
- 1
par example a=4 b=5 c=6 d=1 b=a ----> b=4 c=a+b -----> c=4+5 ---->c=9 d=c-a ----> d=6-4 ---->d=2 d==b ---> 2==4 Not Equal --> false
24th Jun 2017, 4:32 PM
Elie Douaihy
Elie Douaihy - avatar