What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Replace Problem

Replace Problem
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Replace Problem
How is y defined? If you're storing values in an Array variable using string keys, then you're storing them as properties in the Object and not as elements in the Array.
js code:
var a = [];
a[0] = "hello"; // stored as array element
Debug.Trace(a.length); // = 1, as you would expect
a["foo"] = "bar"; // stored as object property
Debug.Trace(a.length); // = 1, problem?

Debug.Trace(a.shift()); // = "hello", as you would expect
Debug.Trace(a.shift()); // = undefined, instead of the 'expected' "bar"
If you don't need any of the Array features such as .length, .pop() or .slice(), simply make it an Object:
js code:
var y = {};
That way, you don't need any of those .hasOwnProperty() checks to skip any unwanted methods from the prototype, since Object.prototype should be empty.

It'd also help if you gave your variables decent names. How will you know what x[0] and y were when you look at your code again in a few months?
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
08-03-2011 08:50 AM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Replace Problem - by Spunky on 08-02-2011 at 08:21 PM
RE: Replace Problem - by matty on 08-02-2011 at 08:33 PM
RE: Replace Problem - by Spunky on 08-02-2011 at 08:36 PM
RE: Replace Problem - by Eljay on 08-02-2011 at 08:48 PM
RE: Replace Problem - by whiz on 08-02-2011 at 08:48 PM
RE: Replace Problem - by Spunky on 08-02-2011 at 08:52 PM
RE: Replace Problem - by Eljay on 08-02-2011 at 09:00 PM
RE: Replace Problem - by Spunky on 08-02-2011 at 09:02 PM
RE: Replace Problem - by Matti on 08-03-2011 at 08:50 AM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On