+ 1

What if I send null as one parameter and try to perform operation on it in the function like adding, then what would the function return?

16th Apr 2016, 6:50 AM
zainul abedin
zainul abedin - avatar
3 Respuestas
+ 4
I think null will be considered 0 for the addition operator. For example: function sum(x, y) { return x+y; } document.write(sum(10, null)); This will print 10.
26th May 2016, 12:50 PM
James Flanders
0
null is nothing. 0.
10th Jun 2016, 11:45 PM
ZinC
ZinC - avatar
0
javascript amazes me sometimes. so null (not nothing btw) will be interpreted as 0?
27th Sep 2016, 9:08 PM
Menno Guldemond
Menno Guldemond - avatar