0
Plz explain
Var str=“abc”; Var arr =[1,2,3]; str.length =2; are.length=2; Console.log(str.length +arr.length); Why answer is 5 not 6
2 Antworten
+ 1
In javascript string are immutable so str.length=2 dont have any effect
But array is mutable when you change its length it will change
So because str is immutable its length stay at 3
And array length now is 2
3+2=5
0
thank you so much u explained so well