Hatena::Groupmnemonic

きおく屋めがねばし

 | 

2012-11-18

「3.2.3 文字列の操作」

Working with Strings

var s = "hello, world"
s.charAt(0)
s.charAt(s.length-1)
s.substring(1,4)
s.slice(1,4)
s.slice(-3)
s.indexOf("l")
s.lastIndexOf("l")
s.indexOf("l", 3)
s.split(", ")
s.replace("h", "H")
s.toUpperCase()

In ECMAScript 5, strings can be treated like read-only arrays, and you can access individual characters (16-bit values) from a string using square brackets instead of the charAt() method:

s = "hello, world";
s[0]           // => "h"
s[s.length-1]  // => "d"

with the notable exception of IE


トラックバック - http://mnemonic.g.hatena.ne.jp/paragramma/20121118
 |