Skip to content

Instantly share code, notes, and snippets.

@niyazpk
niyazpk / index.html
Created December 27, 2011 15:01
Chess
<!doctype html>
<html>
<head>
<meta charset='utf-8'>
<title>JavaScript Chess</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div id='board'>
</div>
User-agent: *
Disallow: /wp-admin
Disallow: /wp-includes
User-agent: *
Disallow: /wp-content/
Disallow: /wp-icludes/
Disallow: /trackback/
Disallow: /wp-admin/
Disallow: /archives/
Disallow: /category/
Disallow: /tag/*
Disallow: /tag/
myArray = ['a', 'b', 'c', 'd'];
delete myArray[1];
// ['a', undefined, 'c', 'd'];
myArray.splice(1, 1)
// ['a', 'c', 'd'];
// subscript notation []
list = [1, 2, 3];
list[list.length] = 4;
// don't use dot notation with arrays
// Templates:
param = { media: 'http://media.valvion.com/' };
url = "{media}logo.gif".supplant(param);
// Unfortunately, supplant method is not there in ES5 spec,
// so use the below prototype:
if (!String.prototype.supplant) {
String.prototype.supplant = function (o) {
//Convert a Number to a String
str = num.toString()
str = String(num)
//Convert a String to a Number
num = Number(str);
num = +str;
num = parseInt(str, 10);
parseInt("12em") === 12 // stops at first non digit
var long_line_1 = "This is a \
long line"; // ok
var long_line_2 = "This is a \
long line"; // syntax error
// because there is a space after \ in the second statement
if( !Number.prototype.trunc ) {
Number.prototype.trunc = function trunc(number){
return Math[ number >=0 ? 'floor' : 'ceil' ](number);
};
}
// extensible - boolean
Object.isExtensible(object) // find out if an object is extensible
Object.preventExtensions(object) // You cannot add any more properties.
Object.seal(object) // Cannot delete properties anymore.
Object.freeze(object) // seals + makes every property read-only