zoukankan      html  css  js  c++  java
  • A brief look at the Objects in JavaScript

    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

      

  • 相关阅读:
    [error]The command could not be located because '/usr/bin' is not included
    hadoop伪分布式
    ssh免密码登录
    移动端中的陀螺仪,摇一摇
    利用百度地图做的定位,获取位置和经纬度
    租房短租发布场地,工作中遇到的复杂日期插件功能
    深入理解定时器系列第三篇——定时器应用(时钟、倒计时、秒表和闹钟)
    BOM之navigator对象和用户代理检测
    jq css3实现跑马灯+大转盘
    Vue小事例
  • 原文地址:https://www.cnblogs.com/beyond-Acm/p/4794509.html
Copyright © 2011-2022 走看看