473,419 Members | 1,839 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,419 software developers and data experts.

Frustrating...

Why does alert(data[i][3]); work fine while var subject = data[i][3];
give me the error, "Error: data[i] has no properties"?

for (i = 0; i < (data.length); i++) {
alert(data[i][3]); //this works fine!
var subject = data[i][3]; //this gives error!
var sender = data[i][4];
var date = data[i][5];
}

Thanks for your help.

Trevor

Feb 12 '06 #1
5 1203
Trevor wrote:
Why does alert(data[i][3]); work fine while var subject = data[i][3];
give me the error, "Error: data[i] has no properties"?

for (i = 0; i < (data.length); i++) {
The inner parantheses are redundant, and

for (var i = 0, len = data.length; i < len; i++)
{

is safer and more efficient. And since order does not seem to matter,
the following is even more efficient:

for (var i = data.length; i--;)
{
alert(data[i][3]); //this works fine!
var subject = data[i][3]; //this gives error!
var sender = data[i][4];
var date = data[i][5];
}


That depends on your data. Literally.

However, I rather think you did not locate the actual error properly.
PointedEars

P.S.: Do not use the tab character to indent (posted) source code.

P.P.S.: Do not misuse the Subject header for expressing your feelings;
Use it to describe the subject of your posting, because the
Subject header is the first thing anyone sees of your posting,
and it influences his/her decision to read or not to read the
posting.
Feb 12 '06 #2
The inner parantheses are redundant, and

for (var i = 0, len = data.length; i < len; i++)
{

is safer and more efficient. And since order does not seem to matter,
the following is even more efficient:

for (var i = data.length; i--;)
{

Just out of curiosity, is there any performance benefit in using --i?

--
Ian Collins.
Feb 13 '06 #3
Ian Collins wrote:
The inner parantheses are redundant, and

for (var i = 0, len = data.length; i < len; i++)
{

is safer and more efficient. And since order does not seem to matter,
the following is even more efficient:

for (var i = data.length; i--;)
{

Just out of curiosity, is there any performance benefit in using --i?


Generally, some say so. Specifically, there is none here as you want
evaluation of `i' as continue-condition _before_ its value is decreased.
Using `--i' here instead would force you to compare `--i > -1' and the
like to achieve the same, while you do not need to with `i--' as `0'
evaluates to `false' in (this) boolean expression(s) already.

Please provide attribution of quoted material; your Mozilla includes
that line automagically for a reason.
PointedEars
Feb 13 '06 #4
Thomas 'PointedEars' Lahn wrote:
Ian Collins wrote:

The inner parantheses are redundant, and

for (var i = 0, len = data.length; i < len; i++)
{

is safer and more efficient. And since order does not seem to matter,
the following is even more efficient:

for (var i = data.length; i--;)
{

Just out of curiosity, is there any performance benefit in using --i?

Generally, some say so. Specifically, there is none here as you want
evaluation of `i' as continue-condition _before_ its value is decreased.


Thanks, I was just curious if prefix operators were faster than postfix.
I had assumed they were.
Please provide attribution of quoted material; your Mozilla includes
that line automagically for a reason.

Slip of the mouse...

--
Ian Collins.
Feb 13 '06 #5
Thomas 'PointedEars' Lahn wrote:
Trevor wrote:


[snip]
for (i = 0; i < (data.length); i++) {


The inner parantheses are redundant, and

for (var i = 0, len = data.length; i < len; i++)
{

is safer and more efficient.


Why is it *safer* ?

--
Riccardo
Feb 13 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: sjanie | last post by:
The error code is: Microsoft JScript compilation error '800a03ec' Expected ';' /bicc.nl/Connections/BICCwebsite.asp, line 2 Set Conn = Server.CreateObject("ADODB.Connection") ----^
11
by: Michael Lang | last post by:
You'd think that the advantage to extra decimal places in a data type is better accuracy. Well think again. Look at this method and test results: ...
0
by: Marina | last post by:
I copied my project on a new computer and try to debug it. When solution is built the exe.config file is completely gone !!!! (not jast from the project but from the hard drive too). Can...
1
by: John | last post by:
Hi I have a very frustrating problem. I had a perfectly working app with a sub form on a main form. I added a few fields in tables here and there and now I can not enter data on in the sub form...
0
by: Rob Levine | last post by:
(This post also available at http://roblevine.blogspot.com/2004/11/frustrating-http-connection-behaviour.html in a slightly more readable format!) Hi All, I seem to be having a bit of a...
3
by: David Cho | last post by:
I've noticed that my code in InitializeComponent where I am linking event handlers to events vanishes from time to time. One of the things that triggers the disappearance is when I do something...
3
by: Loui Mercieca | last post by:
Hi, I have a very strange and frustrating error. I developed an application, tested it and it works fine. Then i deploy it to another machine ( no installation, direct file transfer ) but it...
2
tpgames
by: tpgames | last post by:
Not a question. Just didn't know where to put this montage. So realtek gave me a exe that will create a dump. The device refused saying that it only works with realtek. Like Duh! So, I let the...
4
karlectomy
by: karlectomy | last post by:
Can anyone find the parse error on the fourth line of this stuff?? <table><tr> <td>Date</td> <? var $thisDate = time(); //NOW var $day1 = (7*3600); //One more day for($i = 7; $i>=0; $i--) {
3
by: Sejoro | last post by:
At this point in life, I thought syntax wouldn't be a problem, but it is. I'm trying to write yet another school program, but keep getting compile errors in the main function when I try to pass an...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.