Objects 
An object is a self-contained collection of data. This data comes in to forms:  properties and methods
  • A property is a variable belonging to an object
  • A method is a function that the object can invoke
 
In JavaScript you can create your own objects , called user-defined objects.
JavaScript also coms with a range of premade objects that you can use in your scipts. These are called 
native objects .
 
You may have been seen objects in action. Array is an object.
Whenever you initialize an array using the new keyword, you are creating a new instance of the
objects.when you want to find out how many elements are in an array, you do so by using the length property.
eg :  var beatles = new Array();
        beatles.length;
 
Other native objects examples include Math and Date, both of which have very useful methods for dealing 
with numbers and datas respectively.
For example : 
    var num = 7.561;
    var num = Math.round(num) ;
The Date object can be used to store and retrive infomation about a specific date and time.
If you create a new instance of the Date object, it will be automatically be prefilled with the current date
and time : eg :
  var current_date = new Date();
  var today = current_date.getDay();
 
Host objects 
Native objects arent the only kind of premade objects that you can use in your scripts. 
Another kind of objects supplied not by the JavaScript language itself, but by the environment in 
which its running. In the case of Web, the environment is the web browser. 
Objects that are supplied by the web browser are called host objects.
Host objects include Form, Image, and Element. These objects can be used to get information 
about forms, images, and form elements within a web pages.

So lets take a summary of the objects in JavaScript, There are three kinds of objects in JavaScript :

  •   User-defined objects created from scratch by the programmer.
  •   Native objects like Array, Math and Date, which are built in to JavaScript
  •   Host objects that are provided by the browser

最新文章

  1. [Android Pro] android控件ListView顶部或者底部也显示分割线
  2. JQuery DOM clone(true),对于克隆对象事件触发后,处理函数中this指代克隆对象
  3. mac 下如何切换jdk的版本
  4. schtasks在win7下提示错误:无法加载列资源
  5. Qt之QRoundProgressBar(圆形进度条)
  6. nginx path_info问题解决
  7. Win7下VS2010使用STLPort 和boost1.56.
  8. xhr的send方法以及node如何处理get和post数据
  9. 项目构建之maven篇:3.m2eclipse使用
  10. openSUSE 安装
  11. iOS数据持久化之数据库:SQLite和FMDB
  12. TCP协议简介
  13. Android微信登录、分享、支付
  14. Zuul(SpringCloud学习笔记一)
  15. 30分钟,让你彻底明白Promise原理
  16. mysql5.7 root用户默认密码
  17. 六、框架<iframe>、背景、实体
  18. 使用sshfs挂载远程服务器目录
  19. JavaScriptConverter
  20. MyBatis数据库连接的基本使用

热门文章

  1. 读取java配置文件properties
  2. 移动端toast 提示,HTML css 全屏垂直水平居中
  3. 在LINUX系统中MySQL数据库区分表名的大小写--解决办法
  4. 构建第一个Spring Boot2.0应用之集成mybatis、Druid(七)
  5. Android 浮动按钮的伸缩效果
  6. jqGrid中multiselect: true 操作checkbox
  7. 远程链接mongoDB robomongo
  8. ShopNC B2B2C多用户商城网站系统源码
  9. POI对EXCEL的操作【重点:如何设置CELL格式为文本格式】
  10. 快速开发一个PHP扩展