Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ JavaScript notes --Objects     - 17 How to install the Ubuntu 14.04 and Linux Mint Kodi14 (XBMC) (Linux)

- lolcat: an output terminal rainbow effects in the Linux command-line tool (Linux)

- Proficient in C / C ++ can also find a very good job (Programming)

- Docker data container protection the pros and cons (Server)

- Taught you how to install Ubuntu Linux (Linux)

- Linux use additional rights (Linux)

- How to install open source ITIL portal iTOP on CentOS 7 (Server)

- PL / SQL how to make the program every few seconds to insert a data (Database)

- Linux common network tools: Scan routing of mtr (Linux)

- List Leaves (Programming)

- How ONLYOFFICE collaborative editing document on Linux (Linux)

- Android thread mechanism --AsyncTask (Programming)

- Oracle 11g + RAC + RHEL6.5 + udev + ASM + PSU installation summary (Database)

- Xshell configure SSH free password (Server)

- Eclipse 3.7.2 can not start solving under Ubuntu 14.04 (Linux)

- Deploy OpenStack Juno on Ubuntu 14.04 (Linux)

- The Linux kernel and AVL tree in red-black tree (Programming)

- Getting CentOS Learning Notes (Linux)

- How to avoid two Chrome icon appears in ELementary OS Freya (Linux)

- Practical Handbook: 130+ improve the efficiency of commonly used commands Vim (Linux)

  JavaScript notes --Objects
  Add Date : 2017-08-31      
  JavaScript simple data types: numeric, string, true / false, null and undefined. All other values are objects. Arrays are objects, methods and object. Attribute value is any value other than open undefined values. JavaScript properties can change. And C # dynamic similar to dynamic class.

I. object declaration and initialization.

1. property contains "-" and "" quotation marks when needed, for the "_" unquoted

var stooge = {
        "First Name": "Frank",
        "Last Name": "Zhang"
    } Var person = {
        name: "Frank",
        Age: 23,

      II. Retrieval.

1. retrieve the value of the object can be obtained through the [] and.

2. If the assigned time, the property does not exist. Then automatically creates the property and assigns.

3. Retrieve .propertyName if there is no output undefine;

4. Get undefine, .PropertyName null data will be given, if the data is non-null and non-undefine error will not even be assigned a number.

    console.log (person.name);

    stooge [ "middle Name"] = "C"; // attribute does not exist, re-create the property
    console.log ( "." "." "My full name is" + stooge [ "first Name"] + + stooge [ "middle Name"] + + stooge [ "last Name"]); //Frank.C. Zhang

    console.log (person.vip); // no error, output undefine
    try {
        console.log ( "test" + person.Vip.Msg); // .vip not declared, then the object will get .msg error
    } Catch (ex) {
        console.log (ex.message); // output Can not read property 'Msg' of undefined
    person.Vip = null;
    try {
        console.log ( "test" + person.Vip.Msg); // .vip not declared, then the object will get .msg error
    } Catch (ex) {
        console.log (ex.message); // output Can not read property 'Msg' of null

    person.Vip = 1;
    try {
        console.log (person.Vip.Msg); // output undefine
    } Catch (ex) {
        console.log (ex.message);

III. Reflection

    console.log (person.hasOwnProperty ( "name")); // true
    console.log (typeof (person.Age)); // number
    console.log (typeof (person.toString)); // function

IV. Traversal

1. traverse the object when, name is the name of the property instead of the corresponding property value;.

2. Obtain the property value or through [] and access.;

for (var name in stooge) {
        console.log (name);
        console.log (typeof (name));

        console.log (stooge [name]);
        console.log (typeof (stooge [name]));

V. deleted.

1. Delete Attribute removed via delete obj.propertyName.

VI. Local class

Notes: global variables in front of the class we are using the global variables used in the program will reduce the excessive flexibility, and the development will encounter duplicate naming issues namespace in C #, in Java also has package,. in fact, we can name a JavaScript object. Then package their own specific data into objects. To achieve isolation.

var MyNamespace = {};
    MyNamespace.person = {
        name: "Frank",
        Age: 23

    console.log (MyNamespace.person.name);
- CentOS 6.5 start ActiveMQ being given to solve (Server)
- Create a project using Android Studio LinearLayout (Programming)
- tcpdump Linux system security tools (Linux)
- Redis application of Sina Weibo (Database)
- MongoDB query statistics grouping remove duplicate records (Database)
- New features of Java 9 HTTP2 and REPL (Programming)
- The OpenGL ES GLFW window structures (Programming)
- CentOS 7 How to connect to a wireless network (Linux)
- MySQL thread cache thread_cache_size parameter optimization (Database)
- Talk about jsonp (Programming)
- Linux into single user mode to modify the administrator password (Linux)
- How to install Wine 1.7.20 under Ubuntu or Linux Mint (Linux)
- Linux simple commands (Linux)
- Why HBase need to build SQL engine layer (Database)
- Linux System Getting Started Learning: Disable HTTP forwarding wget in (Linux)
- Unable to solve the official version of Android Studio online update problem (Linux)
- Linux server disk expansion and Oracle tablespace file migration operations (Database)
- Monitoring Linux System 7 command-line tool (Linux)
- Android Notification (Programming)
- Java interview questions in nine radio (Programming)
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.