tipos de datos String en javascript
> 'asdasdasd'
'asdasdasd'
> 'Mar\'s hat'
'Mar\'s hat'
> "\"Hola mundo\" heyy"
'"Hola mundo" heyy'
> var x='fsdfsdf'
undefined
> x.length
7
> "cat" + "say" + "meow"
'catsaymeow'
> var distance = 5
undefined
> "the dog has " + distance + "km"
'the dog has 5km'
> 5 + 3 + "hola mundo"
'8hola mundo'
> "" + 5 +3 + "hola mundo"
'53hola mundo'
> "wishy washy wonky".indeof("wash")
> "hola mundo".substr(5,5)
'mundo'
> "hola mundo".slice(5,10)
'mundo'
> "a,b,c,d,e,f,".split(",") //divide en un arreglo
[ 'a',
'b',
'c',
'd',
'e',
'f',
'' ]
> "sdfsdfsdf ".trim() //quita espacios
'sdfsdfsdf'
EXPRESIONES REGULARES
> "aaoo".replace(new RegExp("[oO]{2,}","b")
...
> "aaoo".replace(new RegExp("[oO]{2,}"),"b")
'aab'
No hay comentarios:
Publicar un comentario