Skip to content

Instantly share code, notes, and snippets.

@watagashi
Created September 8, 2011 14:04
Show Gist options
  • Save watagashi/1203473 to your computer and use it in GitHub Desktop.
Save watagashi/1203473 to your computer and use it in GitHub Desktop.
#tkbjs p.101-
// p.101
// String
var name= 'Curly';
var initial = name.charAt(0);
var s = 'C'.concat('a', 't');
var text = 'Mississippi';
var p = text.indexOf('ss');
p = text.indexOf('ss', 3);
p = text.indexOf('ss', 6);
var text = 'Mississippi';
var p = text.lastIndexOf('ss');
p = text.lastIndexOf('ss', 3);
p = text.lastIndexOf('ss', 6);
var m = ['AAA', 'A', 'aa', 'Aa', 'aaa'];
m.sort(function (a, b) {
return a.localeCompare(b);
});
var text = '<html><body bgcolor=linen><p>' +
'This is <b>bold<\/b>!<\/p><\/body><\/html>';
var tags = /[^<>]+|<(\/?)([A-Za-z]+)([^<>]*)>/g
var a, i;
a = text.match(tags);
for (i = 0; i < a.length; i += 1) {
document.writeln(('// {' + i + '} ' + a[i]).entityify());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment