webproger > cheat sheets > JavaScript
 
Proverbs and Quotes in English
Short sentences and easy words.
 
charAt, charCodeAt, fromCharCode
<!DOCTYPE html><html><head>
</head><body>
<script>
  var c = 3;
  var s = "대한민국";
  for(i=0; i<s.length; i++) {
    document.write(s.charCodeAt(i));
    document.write(' ');
    document.write(s.charAt(i));
    document.write('<br>');
  }
  var ...
742 SHARED
 
charCodeAt, fromCharCode
s = '대한민국\nKorea';
s = s.replace("\n","\\n");
for(i=0; i<s.length; i++) {
  n = s.charCodeAt(i);
  c = String.fromCharCode(n);
  document.write('<br>'+n+' '+c);
}
2634 SHARED
 
exec
<script>
  var s = "JavaScript MySQL";
  var r = /[0-9a-z]+/g;
  while(a=r.exec(s)) {
    document.write('<br>'+a);
  }
</script>

ava
cript
y
2630 SHARED
 
RegExp, match, replace
function sv(v) {
  var r = new RegExp("&s=[0-9]+");
  if(window.location.href.match(r))
       window.location.href = window.location.href.replace(r,"&s="+v);
  else window.location.href = window.location.href+"&s="+v;
}

var ur = document.getElementById( ...
3499 SHARED
 
setTimeout
s = '';
i = 0;
function f1( ) { s += ' B'+i; }
function f2(j) { s += ' C'+j; }

window.setTimeout("s += ' A'+i;",1000);
window.setTimeout(f1( ),2000);
window.setTimeout(f2(i),3000);
i++;
// B0 C0 A1


function r() {
  window.setTimeout("s += ' A'+i;",1000 ...
253 SHARED

-