Giter Site home page Giter Site logo

Comments (13)

ericyang89 avatar ericyang89 commented on June 2, 2024 1

Logical operators 逻辑操作符
There are three logical operators in JavaScript: || (OR), && (AND), ! (NOT).
在JavaScript中,有3个逻辑操作符。分别是||(或),&&(且),!(非)。

Although they are called “logical”, they can be applied to values of any type, not only boolean. The result can also be of any type.
虽然叫做逻辑操作符,他们可以用于任意类型(包括布尔类型),返回的结果也一样。
Let’s see the details.
下面我们来看看具体的示例:

I have more than two years javascript development experience , and I a team leader of a small team of FrontEnd Engineers. I have read a lot of books about javascript ,including

  • JavaScript: The Good Parts
  • JavaScript: The Definitive Guide
  • You Don't Know JS seriers
  • Professional JavaScript for Web Developers
  • ECMA-262-3 in detail (seriers of articals by Dmitry Soshnikov )

from javascript-tutorial.

linhe0x0 avatar linhe0x0 commented on June 2, 2024 1

Error handling, "try..catch"

错误处理 "try..catch"

No matter how great we are at programming, sometimes our scripts have errors. They may occur because of our mistakes, an unexpected user input, an erroneous server response and for a thousand of other reasons.

不管我们在编程方面做的有多好,有时候我们的脚本还是会出现错误。它们可能是因为我们的失误、非预期的用户输入、错误的服务端响应或者其他的上千个原因而发生。

Usually, a script "dies" (immediately stops) in case of an error, printing it to console.

通常情况下,如果发生了错误,脚本会“死掉”(立即停止),并将错误打印到控制台。

But there's a syntax construct try..catch that allows to "catch" errors and, instead of dying, do something more reasonable.

但是有一个语法结构 —— try..catch 可以允许你来“捕捉”错误,并且做一些更合理的事情,而不是让脚本“死掉”。

[cut]

The "try..catch" syntax

"try..catch" 语法

The try..catch construct has two main blocks: try, and then catch:

try..catch 结构有两个主要的部分:try, 和 catch:

try {

  // code...

} catch (err) {

  // error handling

}

It works like this:

它是这么工作的:

1. First, the code in `try {...}` is executed.
2. If there were no errors, then `catch(err)` is ignored: the execution reaches the end of `try` and then jumps over `catch`.
3. If an error occurs, then `try` execution is stopped, and the control flows to the beginning of `catch(err)`. The `err` variable (can use any name for it) contains an error object with details about what's happened.    
  1. 首先,try {...} 中的代码会被执行。
  2. 如果没有错误发生,那么 catch(err) 会被忽略:程序执行完 try,之后跳过 catch
  3. 如果有错误发生,try 中的脚本会被停止执行,并且控制会转移到 catch(err) 的开头。err 变量(可以使用任何名称)包含一个错误对象,其中包含了有关发生的情况的详细信息。

from javascript-tutorial.

maoxiaoke avatar maoxiaoke commented on June 2, 2024 1

An introduction to JavaScript

JavaScript的简介

Let's see what's so special about JavaScript, what we can achieve with it and which other technologies play well with it.
让我们看看JavaScript到底有什么特别之处,通过它我们能得到什么,它又能更好地发挥哪些技术。

What is JavaScript?

什么是JavaScript

JavaScript was initially created to "make webpages alive".
JavaScript的最初目的是为了让网页生动起来
The programs in this language are called scripts. They can be written right in the HTML and execute automatically as the page loads.
这门语言中的程序我们称之为脚本。脚本可以直接写进HTML文档中,然后随着页面加载自动执行。
Scripts are provided and executed as a plain text. They don't need a special preparation or a compilation to run.
脚本可以以纯文本的方式提供并执行,不需要特别的准备或编译就能运行它。
In this aspect, JavaScript is very different from another language called Java.
在这个层面上,JavaScript和另一种编程语言Java就非常不同。

When JavaScript was created, it initially had another name: "LiveScript". But Java language was very popular at that time, so it was decided that positioning a new language as a "younger brother" of Java would help.

But as it evolved, JavaScript became a fully independent language, with its own specification called [ECMAScript](http://en.wikipedia.org/wiki/ECMAScript), and now it has no relation to Java at all.
在JavaScript被创造的初期,有过另外一个名字:LiveScript。但是当时Java语言非常流行,考虑到对其语言的推广,所以最后决定将它定位于Java的“年轻的小弟”。

但是,随着它的演变,JavaScript编程一个完全独立的语言,有着自己的编程规范,称为“ECMAScript”。可以这么说,现在它和Java一点关系都没有。

At present, JavaScript can execute not only in the browser, but also on the server, or actually on any device where exists a special program called the JavaScript engine.

目前,JavaScript不单单可以在浏览器端执行,还可以在服务器端执行。或者更确切地说,它可以在任何存在JavaScript引擎的设备中执行。

from javascript-tutorial.

ericyang89 avatar ericyang89 commented on June 2, 2024

I waner join you @sqrthree

from javascript-tutorial.

iliakan avatar iliakan commented on June 2, 2024

Translation will be published at cn.javascript.info with credits to translators, sounds good?

from javascript-tutorial.

linhe0x0 avatar linhe0x0 commented on June 2, 2024

Great, how shall we start?

from javascript-tutorial.

iliakan avatar iliakan commented on June 2, 2024

Are you good at JavaScript?

你可以翻译一点就给我看看?

from javascript-tutorial.

maoxiaoke avatar maoxiaoke commented on June 2, 2024

It's nice idea. I am in @sqrthree

from javascript-tutorial.

iliakan avatar iliakan commented on June 2, 2024

https://github.com/iliakan/javascript-tutorial-cn is created, with you as collaborators. I'll check the local server, maybe clean it up a little bit and get back to here soon.

from javascript-tutorial.

iliakan avatar iliakan commented on June 2, 2024

Okay it's here: https://github.com/iliakan/javascript-tutorial-server -- install it to edit/translate the tutorial locally, the instruction is at https://github.com/iliakan/javascript-tutorial-server/blob/master/INSTALL.md.

Note that it only runs at Unux/MacOS systems, as Windows is not supported by many Node.JS modules. Any of you on Windows? It's possible to make a virtual machine for things to work, had no reason to do it yet.

Also, to translate the illustrations, you need Sketch editor (Mac only). If that's a problem, you can skip them for now and concentrate on the text.

Please synchronize the translation, not to do the same twice.

from javascript-tutorial.

linhe0x0 avatar linhe0x0 commented on June 2, 2024

@iliakan Some of our members also want to participate in the translation. Can they join us? BTW, We can maintain the quality of translation by the mutual review.

from javascript-tutorial.

iliakan avatar iliakan commented on June 2, 2024

@sqrthree sure, they want commit access, or you will merge their PRs?

from javascript-tutorial.

linhe0x0 avatar linhe0x0 commented on June 2, 2024

OK, I can handle their PRs.

from javascript-tutorial.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.