Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Cleaning arrays
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Steve Onnis  
View profile  
 More options Jul 14 2011, 8:54 pm
From: "Steve Onnis" <st...@cfcentral.com.au>
Date: Fri, 15 Jul 2011 10:54:46 +1000
Local: Thurs, Jul 14 2011 8:54 pm
Subject: Cleaning arrays

Why would this not work?

console.log(Array.from((",1,2,3,4").split(",")).clean())

The first item is returned as an empty string but i don't want it there at
all...

Steve


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul Saukas  
View profile  
 More options Jul 14 2011, 9:02 pm
From: Paul Saukas <arasoihe...@gmail.com>
Date: Thu, 14 Jul 2011 21:02:52 -0400
Local: Thurs, Jul 14 2011 9:02 pm
Subject: Re: [Moo] Cleaning arrays

Because just '' has defind a blank string value. Clen will only remove a
NULL or an Undefined value. you will want erase to get the effect you are
looking for

console.log(Array.from((",1,2,3,4,").split(",")).erase(''))


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul Saukas  
View profile  
 More options Jul 14 2011, 9:07 pm
From: Paul Saukas <arasoihe...@gmail.com>
Date: Thu, 14 Jul 2011 21:07:36 -0400
Local: Thurs, Jul 14 2011 9:07 pm
Subject: Re: [Moo] Cleaning arrays

Let me try that again as i forgot a key bit :) Array.from will create the
blank string value to fill in for undefined

the console out put from your code   ["", "1", "2", "3", "4"]. As to why it
does that the mootools devs will know better then me. I just know it does it
:D


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ryan Florence  
View profile  
 More options Jul 15 2011, 12:10 am
From: Ryan Florence <rpflore...@gmail.com>
Date: Thu, 14 Jul 2011 22:10:42 -0600
Local: Fri, Jul 15 2011 12:10 am
Subject: Re: [Moo] Cleaning arrays

',1,2,3'.split(',') creates an empty string for the first element.

Array.clean only gets rid of null values and '' != null

You'll want to use Array.filter.

On Jul 14, 2011, at 6:54 PM, Steve Onnis wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »