Hi,
A tweet can contain 140 UTF-16 characters.
An UTF-16 character can be composed of 2 16-bits surrogates.
A UTF-16 surrogate can be used to store 10 bits.
An ASCII character is 7 bits long.
Hi,
A tweet can contain 140 UTF-16 characters.
An UTF-16 character can be composed of 2 16-bits surrogates.
A UTF-16 surrogate can be used to store 10 bits.
An ASCII character is 7 bits long.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl https://npmjs.org/install.sh | sh |
Cet article présente les différentes manières de faire de l'héritage en JavaScript. Il répondra aussi à ces questions :
What are we trying to observe? Raw object data.
// Objects
var obj = { id: 2 };
obj.id = 3; // obj == { id: 3 }
// Arrays
var arr = ['foo', 'bar'];
arr.splice(1, 1, 'baz'); // arr == ['foo', 'baz'];
var bindEvent = function( element, type, eventHandler ) { | |
if ( element.addEventListener ) { | |
element.addEventListener( type, eventHandler, false ); | |
} else if ( element.attachEvent ) { | |
element.attachEvent( "on" + type, eventHandler ); | |
} | |
}; | |
bindEvent(document.getElementById('mon_element'), 'change', function () { | |
alert('je change !'); |
En JavaScript, on ne teste pas qu'un objet appartient à telle classe ou implémente telle interface. Cela n'a pas de sens car un objet JavaScript n'entre dans aucun moule préalablement défini
En gros, en JavaScript, tu ne crées pas un objet à partir d'un moule (classe) qui doit implémenter telle interface, mais tu crées un objet A à partir d'un autre objet B. B devient alors le prototype de A. Le prototype "racine" étant [CODEINLINE]Object[/CODEINLINE]. Le nouvel objet B ainsi créé à partir de A aura ses propres méthodes/attributs et aura également accès à celles de A, puis ensuite à celles du prototype de A, etc. On parle de chaîne de prototype. Si la propriété/méthode n'est pas dans B, on check dans son prototype A, puis dans le prototype du prototype A, etc, jusqu'à remonter la pile jusqu'à [CODEINLINE]Object[/CODEINLINE].
Un "équivalent" de l'interface serait plutôt de tester la présence d'attributs ou de méthodes.
En effet, JavaScript répond au style "[URL="http://fr.wikipedia.org/wiki/Duck_typing"]duc
/** | |
* First, better, "set exports/return" option | |
*/ | |
(function (define) { | |
//The 'id' is optional, but recommended if this is | |
//a popular web library that is used mostly in | |
//non-AMD/Node environments. However, if want | |
//to make an anonymous module, remove the 'id' | |
//below, and remove the id use in the define shim. | |
define('id', function (require) { |