+ 1
Why this given below question's answer is 5 ?
var str = "abc"; var arr = [1,2,3]; str.length=2; arr.length=2; console.log(str.length + arr.length);
2 RĂ©ponses
+ 3
You can change the length of an array value but not the string. Strings are immutable by design. You can't change them.
With âabcâ , the length will always remain 3. Then you changed arr length to 2. In total this gives 5.
+ 2
Thank you friend!đ