Archive for the ‘前端开发’ Category

逐句学英文-对象

Objectsˈɔbdʒikt对象

An object is a collection of named values.
对象是已命名的数据的集合。

These named values are usually referred to as properties of the object.
这些已命名的数据通常被作为对象的属性来引用。

For example, if an object named image has properties named width and height, you can refer to those properties like this:
例如,如果一个名为image的对象有一个名为width和一个名为height的属性,我们可以使用如下方式来引用这些属性:

image.width
image.height

Properties of objects are, in many ways, just like JavaScript variables; they can contain any type of data, including arrays, functions, and other objects.
对象的属性在很多方面都跟 JavaScript 的变量相似,属性可以是任何类型的数据,包括数组、函数和其他对象。

Thus, you might see JavaScript code like this:
所以,读者有可能会见到如下的 JavaScript代码:
document.myform.button

This code refers to the button property of an object that is itself stored in the myform property of an object named document.
这里引用了一个对象的button属性,而这个对象本身又存储在对象document的myform属性中。

When a function value is stored in a property of an object, that function is often called a method, and the property name becomes the method name.
如果一个函数值是存储在某个对象的属性中的,那么那个函数通常被称为方法,属性名也就变成了方法名。

Objects in JavaScript can serve as associative arrays; that is, they can associate arbitrary data values with arbitrary strings.
JavaScript 中的对象可以作为关联词组使用,因为它们能够将任意的数据值和任意的字符串关联起来。

阅读全文 »

逐句学英文-函数

Functionsˈfʌŋkʃən函数

Although a function is defined only once, a JavaScript program can execute or invoke it any number of times.
虽然函数只定义一次,但是JavaScript程序却可以多次执行或调用它。

A function may be passed arguments, or parameters, specifying the value or values upon which it is to perform its computation, and it may also return a value that represents the results of that computation.
函数可以带有实际参数或形式参数,用于指定这个函数执行计算要使用的一个或多个值,而且它还能返回一个值,以表示计算结果。

JavaScript implementations provide many predefined functions, such as the Math.sin() function that computes the sine of an angle.
JavaScript 的实现提供了许多预定义函数,如 Math.sin() ,它用于计算角的正弦值。

JavaScript programs may also define their own functions with code that looks like this:
JavaScript 程序也可以定义自己的函数,代码如下:

function square(x)//定义了一个名为square的函数,它指定了一个参数x
{
 
return x*x; // 返回参数x的平方(值)
}

Once a function is defined, you can invoke it by following the function’s name with an optional comma-separated list of arguments within parentheses. The following lines are function invocations:
一旦定义了函数,只需要在函数名后边加上一个可选的、用逗号分隔的参数列表(该列表用括号括起来),就可以调用它。下面是函数调用的代码:

y = Math.sin(x);
y = square(x);
d = compute_distance(x1,y1,z1,x2,y2,z2);
move();

An important feature of JavaScript is that functions are values that can be manipulated by JavaScript code.
JavaScript 的一个重要特性是 JavaScript 代码可以对函数进行操作。

The fact that functions are true values in JavaScript gives a lot of flexibility to the language.
JavaScript 中的函数是真正的数值,这一点给语言带来了很大的灵活性。

It means that functions can be stored in variables, arrays, and objects, and it means that functions can be passed as arguments to other functions.
这就意味着函数可以被存储在变量、数组和对象中,而且函数还可以作为参数传递给其他函数。

阅读全文 »

逐句学英文-布尔值

Boolean Valuesˈbu:li:ən布尔值

The boolean datatype has two values, these are represented by the literals true and false.
布尔数据类型有2个值,分别由直接量true和false表示。

Boolean values are generally the result of comparisons you make in your JavaScript programs. For example:
布尔值通常在JavaScript程序中比较所得的结果。例如:

a == 4

This code tests to see whether the value of the variable a is equal to the number 4.
这行代码检测了变量a的值是否和数值4相等。

If it is, the result of this comparison is the boolean value true.
如果相等,比较的结果就是布尔值true

If a is not equal to 4, the result of the comparison is false.
如果a不等于4,比较的结果就是false

Boolean values are typically used in JavaScript control structures.
布尔值通常用于JavaScript的控制结构。

For example, the if/else statement in JavaScript performs one action if a boolean value is true and another action if the value is false.
例如,JavaScript的 if/else 语句,就是在布尔值为true时,执行一个动作,而在布尔值为false时,执行另一个动作。

if (a == 4)
 
b = b + 1;
else
 
a = a + 1;

This code checks whether a equals 4. If so, it adds 1 to b; otherwise, it adds 1 to a.
这段代码检测了a是否等于4,如果是,就给b增加1,否则给a加1

阅读全文 »

逐句学英文-字符串

Stringsstriŋ字符串

A string is a sequence of Unicode letters, digits, punctuation characters, and so on; it is the JavaScript datatype for representing text.
字符串是由Unicode字符、数字、标点符号等组成的序列,它是JavaScript用来表示文本的数据类型。

To represent a single character, you simply use a string that has a length of 1.
要表示单个字符,必须使用长度为1的字符串。

阅读全文 »

Page 5 of 17« First...34567...10...Last »
崔凯博客
Powered by SinaSAE | Theme by ck web design | TOP 顶部
Copyright © 崔凯 All rights reserved. 蜀ICP备12025891号.