HighDots Forums  

Split e Join...

Javascript (Italian) Il linguaggio JavaScript (it.comp.lang.javascript)


Discuss Split e Join... in the Javascript (Italian) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Giulio Petrucci
 
Posts: n/a

Default Split e Join... - 11-29-2007 , 04:43 AM






Ciao a tutti,

premesso che non sono certo un esperto di JavaScript, stamattina ho
scoperto che:

var a = new Array(); //vettore di lunghezza 0;
var l = a.length;
var s = a.join(",");
a = s.split(",")
var l2 = a.length;

io mi aspetterei che l==l2, mentre invece ho notato che l=0 e l2=1. C'e'
qualche motivazione particolare alla base di questo comportamento?

Ciao,
Giulio

--
OnAir:
http://petrux.blogspot.com

Reply With Quote
  #2  
Old   
Cristiano Larghi
 
Posts: n/a

Default Re: Split e Join... - 11-29-2007 , 04:48 AM






Il Thu, 29 Nov 2007 10:43:21 +0100, Giulio Petrucci ha scritto:

Quote:
var a = new Array(); //vettore di lunghezza 0;
var l = a.length;
var s = a.join(",");
a = s.split(",")
var l2 = a.length;

io mi aspetterei che l==l2, mentre invece ho notato che l=0 e l2=1. C'e'
qualche motivazione particolare alla base di questo comportamento?
č scritto nella definizione di split:
http://developer.mozilla.org/en/docs...Strin g:split

--
"Voi abili a tenere sempre un piede qua e uno lą
avrete un avvenire certo in questo mondo qua
perņ la dignitą
dove l'avete persa?"
V.R.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.