Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

這一段話的意思譯反了,請參考新譯 #360

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/en/object/forinloop.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ When `hasOwnProperty` is left out, the code is prone to errors in cases where
the native prototypes - e.g. `Object.prototype` -
have been extended.

> Tried in jeforth
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is jeforth, why is this relevant?

> js> [].length . \ ==> 0 OK.
> js> [] obj>keys . \ ==> "" OK.
> js> [].hasOwnProperty("length") \ ==> true (boolean).
> So 'length' is a non-enumerable property of an array.

In newer versions of ECMAScript, non-enumerable properties can be defined with
`Object.defineProperty`, reducing the risk of iterating over properties without
using `hasOwnProperty`. Nonetheless, care must be taken when using older
Expand Down
1 change: 1 addition & 0 deletions doc/en/object/general.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ as objects too.
2..toString(); // the second point is correctly recognized
2 .toString(); // note the space left of the dot
(2).toString(); // 2 is evaluated first
2["toString"](); // alternative notation avoids using the dot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this works, I don't think it's necessary


### Objects as a Data Type

Expand Down
5 changes: 2 additions & 3 deletions doc/zhtw/object/prototype.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
## Prototype

JavaScript 不包含傳統繼承的模型,它使用的是*原型*模型。
JavaScript 不包含傳統的「類」繼承的模型,它使用的是「原型」模型。

儘管常常有人提及 JavaScript 的缺點,但基於原型的繼承模型比傳統繼承更強大。
實現傳統的類繼承模型是很簡單。但是在 JavaScript 中實現原型的繼承模型則要困難很多。
儘管這常被認為是 JavaScript 的缺點,但「原型繼承模型」其實比「類繼承模型」更強大。在「原型繼承模型」上實現傳統的「類繼承模型」是小事一件,但反過來要在只有「類繼承模型」的地方弄出「原型繼承模型」則要困難很多。

由於 JavaScript 是唯一一個被廣泛使用的基於原型繼承的語言,所以我們必須要花時間來理解這兩者的不同。

Expand Down
122 changes: 122 additions & 0 deletions log.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@

[x] The "javascript garden" project needs to be built before browsing according to CONTRIBUTING.md
So I run the build command line:
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

c:\Users\hcche\Documents\GitHub\JavaScript-Garden>npm run build

> [email protected] build c:\Users\hcche\Documents\GitHub\JavaScript-Garden
> node build.js

module.js:327
throw err;
^

Error: Cannot find module 'lodash'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (c:\Users\hcche\Documents\GitHub\JavaScript-Garden\build.js:2:9)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run
" "build"
npm ERR! node v4.4.3
npm ERR! npm v2.15.1
npm ERR! code ELIFECYCLE
npm ERR! [email protected] build: `node build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script 'node build.js'.
npm ERR! This is most likely a problem with the javascript-garden package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node build.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs javascript-garden
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls javascript-garden
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! c:\Users\hcche\Documents\GitHub\JavaScript-Garden\npm-debug.log

c:\Users\hcche\Documents\GitHub\JavaScript-Garden>
[ ] check the error, RI: a module "lodash" is missing. So I studied and found how to install
that module: http://www.w3cplus.com/javascript/lodash-intro.html ( See my Ynote and Evernote )
--> install lodash:
c:\Users\hcche\Documents\GitHub\JavaScript-Garden>npm install --save lodash
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No license field.
[email protected] node_modules\lodash
--> ok? Try building j/g again:
c:\Users\hcche\Documents\GitHub\JavaScript-Garden>npm run build
> [email protected] build c:\Users\hcche\Documents\GitHub\JavaScript-Garden
> node build.js
module.js:327
throw err;
^
Error: Cannot find module 'jade'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (c:\Users\hcche\Documents\GitHub\JavaScript-Garden\build.js:3:12)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
--> so, again, missing 'jade' module.
--> install jade:
c:\Users\hcche\Documents\GitHub\JavaScript-Garden>npm install --save jade
--> try again:
c:\Users\hcche\Documents\GitHub\JavaScript-Garden>npm run build
Error: Cannot find module 'marked'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
--> so, again, missing 'marked' module.
--> install marked:
c:\Users\hcche\Documents\GitHub\JavaScript-Garden>npm install --save marked
--> try again:
c:\Users\hcche\Documents\GitHub\JavaScript-Garden>npm run build

> [email protected] build c:\Users\hcche\Documents\GitHub\JavaScript-Garden
> node build.js

c:\Users\hcche\Documents\GitHub\JavaScript-Garden>
==> OK now, Bingo!
Taget directory c:\Users\hcche\Documents\GitHub\JavaScript-Garden\site
was very empty but now is full of different languages and index.html appears.
[x] Modify the 'prototype.md' to be :
JavaScript 不包含傳統的「類」繼承的模型,它使用的是「原型」模型。
儘管這常被認為是 JavaScript 的缺點,但「原型繼承模型」其實比「類繼承模型」更強大。
在「原型繼承模型」上實現傳統的「類繼承模型」是小事一件,但反過來要在只有「類繼承模
型」的地方弄出「原型繼承模型」則要困難很多。
--> submit --> push to my fork.
[x] How to make a PR (Pull request)?
--> Found a [New pull request] button on my repo's home page. --> click it, switched
to a page "Comparing changes" and it says : Choose two branches to see what’s changed or
to start a new pull request. If you need to, you can also compare across forks. --> so
I check the difference and it's fine. The page also says : "Able to merge. These branches
can be automatically merged." so I am about to proceed.
--> And, for the safe, I rebuilt again:
c:\Users\hcche\Documents\GitHub\JavaScript-Garden>npm run build
> [email protected] build c:\Users\hcche\Documents\GitHub\JavaScript-Garden
> node build.js
and then view the changes on my local browser to make sure it works fine:
file:///C:/Users/hcche/Documents/GitHub/JavaScript-Garden/site/zhtw/index.html#object.prototype
--> OK!
--> There's a button "[Create pull request] Discuss and review the changes in this comparison
with others." and I click it . . .
--> follow the process to provide some descriptions and then submit and DONE!
The pull request is really went to the original repo BonsaiDen/JavaScript-Garden

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"dependencies": {
"fomatto": "0.5.0",
"forever": "0.10.8",
"jade": "0.35.0",
"neko": "1.1.2",
"marked": "~0.2.9",
"lodash": "~2.2.1"
"jade": "^0.35.0",
"lodash": "^2.4.2",
"marked": "^0.2.10",
"neko": "1.1.2"
}
}