Skip to content

Commit 25cfb17

Browse files
authored
Merge pull request #1 from shichuan/master
update
2 parents 27209e8 + bff021b commit 25cfb17

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+11107
-261
lines changed

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#JavaScript Patterns
22

3-
<imgsrc="http://shichuan.github.com/javascript-patterns/img/js-patterns.png"alt="JS Patterns"title="JS Patterns" />
3+
<imgsrc="http://shichuan.github.io/javascript-patterns/img/js-patterns.png"alt="JS Patterns"title="JS Patterns" />
44
<br />
5-
Project page at: <ahref="http://shichuan.github.com/javascript-patterns"target="_blank">http://shichuan.github.com/javascript-patterns</a>
5+
Project page at: <ahref="http://shichuan.github.io/javascript-patterns"target="_blank">http://shichuan.github.io/javascript-patterns</a>
66

‎cn/index.html‎

Lines changed: 233 additions & 0 deletions
Large diffs are not rendered by default.

‎code-reuse-patterns/borrowing-methods.html‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
vartwo={
2929
name:'another object'
3030
};
31-
31+
32+
// apply two to original object one.
3233
console.log(one.say.apply(two,['hello']));// "hello, another object"
3334

3435
// assigning to a variable
@@ -43,7 +44,7 @@
4344
returncallback('Hola');
4445
}
4546
};
46-
console.log(yetanother.method(one.say));// "Holla, undefined"
47+
console.log(yetanother.method(one.say));// "Hola, undefined"
4748

4849
functionbind(o,m){
4950
returnfunction(){
@@ -79,4 +80,4 @@
7980
// http://shop.oreilly.com/product/9780596806767.do
8081
</script>
8182
</body>
82-
</html>
83+
</html>

‎code-reuse-patterns/prototypal-inheritance.html‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,33 @@
3939
Person.prototype.getName=function(){
4040
returnthis.name;
4141
};
42+
4243
// create a new person
4344
varpapa=newPerson();
45+
4446
// inherit
4547
varkid=object(papa);
48+
4649
// test that both the own property
4750
// and the prototype property were inherited
4851
console.log(kid.getName());// "Adam"
4952

50-
5153
// parent constructor
5254
functionPerson(){
5355
// an "own" property
5456
this.name="Adam";
5557
}
58+
5659
// a property added to the prototype
5760
Person.prototype.getName=function(){
5861
returnthis.name;
5962
};
63+
6064
// inherit
6165
varkid=object(Person.prototype);
6266
console.log(typeofkid.getName);// "function", because it was in the prototype
6367
console.log(typeofkid.name);// "undefined", because only the prototype was inherited
6468

65-
6669
/* Addition to ECMAScript 5 */
6770
varchild=Object.create(parent);
6871

0 commit comments

Comments
(0)