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

      

  • 相关阅读:
    native-base中Input,Textarea等组件在ios平台下不能输入中文
    react-native中TextInput在ios平台下不能输入中文
    react-native android/ios 手动/自动 修改版本号
    react-native修改android包名
    React-Native——html/css
    去除npm run dev日志warn记录
    Python并发编程:多进程-互斥锁
    Python并发编程:多进程-守护进程
    Python并发编程:多进程-join方法
    面向对象练习题
  • 原文地址:https://www.cnblogs.com/beyond-Acm/p/4794509.html
Copyright © 2011-2022 走看看