0
an explaination about this JS code, please...
var one =[2,4]; var two =[1,3]; var set =one+two; //set=[2,41,3] alert (set.length); output >> 6 // ?!?
2 odpowiedzi
+ 6
Oneill :D
adding (also alerting using alert(obj)) objects envokes their toString() method. arrays are also objects in js.
first array is converted to => "2,4"
second converted to =>"1,3"
on addition the strings are conactenated "2,41,3"
final product is obviously a string not an array so obviously commas , will also be counted as charecters.
printing length property of "2,41,3" string you get 6 🤝
edit{
see this post by everything.js :
https://www.sololearn.com/post/161927/?ref=app
}
+ 2
thx guys. I understood.
I forgotten the type value