JS 对象介绍
作者:bea
JavaScript is an Object Oriented Programming (OOP) language.
JS是面向对象的编程语言(面向对象)。 (这里是基于对象还是面向对象大家可以搜索下)
An OOP language allows you to define your own objects and make your own variable types.
OOP语言可以让你自定义对象和变量类型。
--------------------------------------------------------------------------------
Object Oriented Programming
被安置对象的编程
JavaScript is an Object Oriented Programming (OOP) language. An OOP language allows you to define your own objects and make your own variable types.
JS是(OOP)语言,这就可以让你定义....(和上面的重复)
However, creating your own objects will be explained later, in the Advanced JavaScript section. We will start by looking at the built-in JavaScript objects, and how they are used. The next pages will explain each built-in JavaScript object in detail.
然而,我们将晚些在高级JS里介绍建立自定义对象。我们将开始观察内建JS对象和如何使用它们。下页将详细介绍每个内建JS对象
Note that an object is just a special kind of data. An object has properties and methods.
注意,对象只是特殊类型的数据。对象有属性和方法
--------------------------------------------------------------------------------
Properties
属性
Properties are the values associated with an object.
属性是对象的相连值
In the following example we are using the length property of the String object to return the number of characters in a string:
下面的例子我么使用了字符串对象的长度属性来返回字符的数量:
<script type="text/javascript">
var txt="Hello World!"
document.write(txt.length)
</script>
The output of the code above will be:
上面的代码就会输出:
12
--------------------------------------------------------------------------------
Methods
方法
Methods are the actions that can be performed on objects.
对象的方法可以执行行为。
In the following example we are using the toUpperCase() method of the String object to display a text in uppercase letters:
下面的例子使用了字符串对象的toUpperCase()方法来显示出文字的大写:
<script type="text/javascript">
var str="Hello world!"
document.write(str.toUpperCase())
</script>
The output of the code above will be:
上面的代码输出:
HELLO WORLD!
猜你喜欢
您可能感兴趣的文章:
- JQuery.uploadify 上传文件插件的使用详解 for ASP.NET
- JQuery 构建客户/服务分离的链接模型中Table中的排序分析
- JQuery 构建客户/服务分离的链接模型中Table分页代码效率初探
- 被jQuery折腾得半死,揭秘为何jQuery为何在IE/Firefox下均无法使用
- jQuery 入门级学习笔记及源码
- JQuery 确定css方框模型(盒模型Box Model)
- Jquery实战_读书笔记2 选择器
- Jquery实战_读书笔记1—选择jQuery
- jquery last-child 列表最后一项的样式
- javascript 拖放效果实现代码
- JAVASCRIPT style 中visibility和display之间的区别
- javascript 获取url参数和script标签中获取url参数函数代码
- javascript 实现自由落体的方块效果
- JavaScript 学习笔记(十三)Dom创建表格
- JavaScript 学习笔记(十二) dom
- javascript parseInt与Number函数的区别
- js parsefloat parseint 转换函数
- jquery 防止表单重复提交代码
- javascript 哈希表(hashtable)的简单实现