473,395 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 1302
Dormilich
8,658 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
608 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

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

Similar topics

1
by: Vincent Nuijjten | last post by:
Hello, My question is: I'm adding character 253 to a javascript string this way: var str = ''; str += 'a'; str += unescape('%FD');
6
by: Dan Webb | last post by:
Hi All, Im currently working on ways of pacakaging javascript functions/variables/objects in a similar way to the Java package statement so that scripts can be interact with each other with the...
5
by: Lucian Sandor | last post by:
Hello everyone, While I'm a newbie here, I a not new to google, so please don't send me back, it would be useless. First of all I have to specify I am working on a Blogger.com template, therefore...
4
by: howachen | last post by:
Hi Some examples use the following codes in order to load external JS... e.g. document.write("<scr"+"ipt language=javascript .... I have one qusestion,
3
by: seanbrasher | last post by:
I have the following code: --------------------------------------------- <html> <head> <script language="javascript"> function readHiddenField() { var string1 = 'hidden_field_l00'; var...
12
by: Water Cooler v2 | last post by:
Are JavaScript strings mutable? How're they implemented - 1. char arrays 2. linked lists of char arrays 3. another data structure I see that the + operator is overloaded for the string class...
7
by: swethasivaram | last post by:
Hello I have a Java-based web application whose interface can be in multiple languages. My requirement is that the javascript alerts that I display should be displayed in the language in which...
6
by: William Pierce | last post by:
Hi, I have an interesting problem that I am stuck on and was wondering if there might be others who can shed some light.... Basically, within an HTML page, I have a tag that looks as...
8
by: starsky51 | last post by:
I'm sure it's something i'm doing wrong, I just can't see it. I've set up a simple page with the following code: <html> <head> <title>tester</title> <script language="javascript"...
7
by: John | last post by:
Hi Everyone, I'm having this extremely annoying problem with Internet Explorer 6, giving me an error message saying "unknown runtime error" whenever I try to alter the contents of a <divelement...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.