469,325 Members | 1,524 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,325 developers. It's quick & easy.

Javascript strings

1
what are the values of thirdVar, fourthVar and fifthVar after these lines of javascript have been executed.

Expand|Select|Wrap|Line Numbers
  1. var firstVar = 'Joseph' ;
  2. var secondVar = ' Locke' ;
  3. var thirdVar = firstVar.charAt (0) + '. ' + secondVar;
  4. var fourthVar = thirdVar.length;
  5. var = 'The last character is' + thirdVar.charAt(fourthVar) + ' ! ' ;
May 29 '10 #1
2 1231
Dormilich
8,651 Expert Mod 8TB
isn’t that obvious? just do mentally, what the JavaScript engine does, it’s not complicated.

PS. aint that Ashley Lynx?
May 29 '10 #2
RamananKalirajan
607 512MB
It will be empty space or null or undefined logically speaking. Because thirdVar.length will have 8. But the thirdVar is a string and it will be stored like [0] -> J, [1] -> ., [2] -> a space, [3] -> L, [4] -> o, [5] -> c, [6] -> k, [7] -> e. This is how the value will be stored. When u try to fetch charAt[8] it will return a empty value, null or exception.

Thanks and Regards
Ramanan Kalirajan
May 30 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Dan Webb | last post: by
5 posts views Thread by Lucian Sandor | last post: by
4 posts views Thread by howachen | last post: by
3 posts views Thread by seanbrasher | last post: by
12 posts views Thread by Water Cooler v2 | last post: by
7 posts views Thread by swethasivaram | last post: by
6 posts views Thread by William Pierce | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.