Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within HTML Pages with CSS and JavaScript
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
HTML Pages with CSS and JavaScript
JavaScript code question
Arjun Reddy
Ranch Hand
Posts: 629
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi All,
I am unable to understand
myArray[4]
and
line no 8
from the below code. Can someone explain me what it means?
<script type="text/javascript"> var myArray = [ 3, 'hello!', function() {return 5}, {'color':'blue', 'budget':25}, /[ell]/i ]; document.writeln('0>'+myArray[0]+'<BR>'); // Will output: 0>3 document.writeln('1>'+myArray[1]+'<BR>'); // Will output: 1>hello! document.writeln('2>'+myArray[2]()+'<BR>'); // Will output: 2>5 document.writeln('3>'+myArray[3].color+'<BR>'); // Will output: 3>blue document.writeln('3>'+myArray[3].budget+'<BR>'); // Will output: 3>25 document.writeln('4>'+myArray[4].test(myArray[1])+'<BR>'); // Will output: 4>true </script>
Thanks.
Be Humble... Be Nice.
Bear Bibeault
Sheriff
Posts: 67746
173
I like...
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I hope this is just academic code and not something that's actually being used for anything!
In any case, [4] is a regular expression, which possesses a
test
() method which is being called.
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
Arjun Reddy
Ranch Hand
Posts: 629
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I found it on this page actually.
http://www.hunlock.com/blogs/Mastering_Javascript_Arrays
Be Humble... Be Nice.
Bear Bibeault
Sheriff
Posts: 67746
173
I like...
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Please do not consider it any sort of valid programming style!
Eeeesh!
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
Arjun Reddy
Ranch Hand
Posts: 629
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
ok
Be Humble... Be Nice.
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
pulling data from xml using javascript
Javascript API
Updated MulitThreads Problem
while-loop
output of this code
More...