我爱编程

2018-06-27 p7-p9

2018-06-28  本文已影响0人  枫叶落尽

方法是对对象而言的,不依赖对象的函数就叫函数。
assigned 赋值
var a = []; // Create an empty array
a.push(1,2,3); // The push() method adds elements to an array数组的push方法,可以添加元素,(之前的一种方法是直接添加,比如a[3]=0;
a.reverse(); // Another method: reverse the order of elements颠倒元素的顺序,注意调用的时候后面的()
// We can define our own methods, too. The "this" keyword refers to the object
// on which the method is defined: in this case, the points array from above.
//this关键字指方法所在的对象
invoked on 调用
above. 上文,前文
var points = [ // An array with 2 elements.
{x:0, y:0}, // Each element is an object.
{x:1, y:1}
];
points.dist = function() { //直接定义方法
var p1 = this[0]; // 相当于points[0]
var p2 = this[1];

The Pythagorean theorem 勾股定理


向一个数组中直接添加函数

b.c获得的是函数体;
b.c()才是调用函数;
必须明确了对象的类型,才能添加函数?
重写页面后好像就返回不回去了

demonstrate common 展示共性
syntax 语法
clause 条款;条件
Curly braces optional when 1 statement per clause.
花括号 可选择的,非强制的,即可要可不要的, 分句,从句
nested inside 嵌入的,嵌套的; 筑巢( nest的过去式和过去分词 ) 内部的 内嵌;
factorials 阶乘 shortcut 缩写
Automatically increment 自增
object-oriented 面向对象 oriented以。。。为方向的
demonstrate 展示
geometric 几何
instances 实例 origin: 原点
constructor function 构造函数
By convention, constructors start with capitals 按照惯例,构造函数以大写字母开头
this.x = x; // this 关键字指代新初始化的实例
arguments 参数
Define methods for Point objects by assigning them to the prototype//通过为prototype对象赋值,来给Point对象定义方法;(prototype对象应该是js对象初始化过程中的一个对象?)
the climax of //高潮,精华,极点
wrap up some loose ends做了零星的延伸
Pattern Matching with Regular Expressions 正则表达式的模式匹配
use these “regexps” for textual pattern matching 使用这些“正则表达式”进行文本模式匹配
Subsets and Extensions 子集与扩展
plunge into 跳入,进入
exhibit 呈现,展览 nonlinear 非线性的
a fairly linear sequence 一个相当线性的序列
long way off 漫长的路程 quick sketch 速写
embedded within 内嵌 embedded植入的,深入的,内含的; 把…嵌入,埋入( embed的
nested inside
modal dialog 对话框
// Run the function defined above 1 minute (60,000 milliseconds) from now.
setTimeout(moveon, 60000); //在60,000毫秒后运行这个函数(moveon);
snippets 片段 wrap 包

End 28 1.14

上一篇下一篇

猜你喜欢

热点阅读