0%

When yester-eve the moon arose, then did I fancy it about to bear a sun: so broad and teeming did it lie on the horizon.

But it was a liar with its pregnancy; and sooner will I believe in the man in the moon than in the woman.

阅读全文 »

Too far did I fly into the future: a horror seized upon me.

And when I looked around me, behold, there time was my sole contemporary.

Then did I fly backwards, homewards- and always faster. Thus did I come to you: you present-day men, and into the land of culture.

阅读全文 »

Calm is the bottom of my sea: who would guess that it hides droll monsters!

Unmoved is my depth: but it sparkles with swimming enigmas and laughters.

A sublime one saw I today, a solemn one, a penitent of the spirit: Oh, how my soul laughed at his ugliness!

阅读全文 »

“Will to Truth” do you call it, you wisest ones, that which impels you and makes you ardent?

Will for the thinkableness of all being: thus do I call your will!

All being would you make thinkable: for you doubt with good reason whether it be already thinkable.

阅读全文 »

“Yonder is the grave-island, the silent isle; yonder also are the graves of my youth. There will I carry an evergreen wreath of life.”

Resolving thus in my heart, did I sail o’er the sea.-

Oh, you sights and scenes of my youth! Oh, all you gleams of love, you divine fleeting gleams! How could you perish so soon for me! I think of you to-day as my dead ones.

阅读全文 »

One evening went Zarathustra and his disciples through the forest; and when he sought for a well, lo, he lighted upon a green meadow peacefully surrounded by trees and bushes, where maidens were dancing together. As soon as the maidens recognized Zarathustra, they ceased dancing; Zarathustra, however, approached them with friendly mien and spoke these words:

Cease not your dancing, you lovely maidens! No game-spoiler has come to you with evil eye, no enemy of maidens.

阅读全文 »

‘TIS night: now do all gushing fountains speak louder. And my soul also is a gushing fountain.

‘Tis night: now only do all songs of the loving ones awake. And my soul also is the song of a loving one.

阅读全文 »

一共5种,除了工厂函数不常用外,其他都很常用。

方式一: Object构造函数模式

  • 套路: 先创建空Object对象, 再动态添加属性/方法
  • 适用场景: 起始时不确定对象内部数据
  • 问题: 语句太多
1
2
3
var obj = new Object()
obj.name = 'Tom'
obj.setName = function(name){this.name=name}

方式二: 对象字面量模式

  • 套路: 使用{}创建对象, 同时指定属性/方法
  • 适用场景: 起始时对象内部数据是确定的
  • 问题: 如果创建多个对象, 有重复代码
1
2
3
4
5
6
7
var p = {
name: 'Tom',
age: 12,
setName: function (name) {
this.name = name
}
}

方式三: 工厂模式

  • 套路: 通过工厂函数动态创建对象并返回
  • 适用场景: 需要创建多个对象
  • 问题: 对象没有一个具体的类型, 都是Object类型
1
2
3
4
5
6
7
8
9
10
function createPerson(name, age) {
var obj = {
name: name,
age: age,
setName: function (name) {
this.name = name
}
}
return obj
}

方式四: 自定义构造函数模式

  • 套路: 自定义构造函数, 通过new创建对象
  • 适用场景: 需要创建多个类型确定的对象
  • 问题: 每个对象都有相同的数据, 浪费内存
1
2
3
4
5
6
function Person(name, age) {
this.name = name;
this.age = age;
this.setName = function(name){this.name=name;};
}
new Person('tom', 12);

方式五: 构造函数+原型的组合模式

  • 套路: 自定义构造函数, 属性在函数中初始化, 方法添加到原型上
  • 适用场景: 需要创建多个类型确定的对象
1
2
3
4
5
6
7
8
function Person(name, age) {
this.name = name
this.age = age
}
Person.prototype.setName = function (name) {
this.name = name
}
new Person('Tom', 23)

The people have you served and the people’s superstition- not the truth!- all you famous wise ones! And just on that account did they pay you reverence.

And on that account also did they tolerate your unbelief, because it was a pleasantry and a by-path for the people. Thus does the master give free scope to his slaves, and even enjoys their presumptuousness.

阅读全文 »