Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ Depth understanding of JavaScript new mechanism     - Install Git on CentOS (Linux)

- The SVN installation, configuration and start - up under Linux (CentOS 6.5) (Server)

- Debian (Wheezy) Install Java environment / replace OpenJDK as the SUN JDK (Linux)

- Oracle can not change the tablespace to backup mode in non-archive mode (Database)

- Python dictionary applications get built-in method (Programming)

- The user how to install Notepadqq 0.41.0 under ubuntu and debian (Linux)

- Manage SQL Server services login (start) account and password (Database)

- Nginx Keepalived Nginx monitoring scripts (Server)

- Ubuntu treated with cue file to ape and wav files automatically track points (Linux)

- Linux Apache server configure to protect system security (Linux)

- Shell scripts to copy all directories under the current directory of a certain type of file to the same directory (Linux)

- CentOS 7.0 Experience with previous versions (Linux)

- CentOS install pip (Linux)

- Into the Java keyword instanceof (Programming)

- MySQL performance view and configure finishing Daquan (Database)

- Copy and paste in Linux terminal and Vim (Linux)

- How to download video youtube-dl in Linux (Linux)

- Use cmake to compile and install MySQL 5.5 (Database)

- Use of the storage-level replication technology will quickly clone a ASM database to the target environment (Database)

- Linux IPTables anti-DDOS attack Shell Scripting (Linux)

  Depth understanding of JavaScript new mechanism
  Add Date : 2018-11-21      
  We use JavaScript object, in addition to some of the browser's built-monomer object can be used directly, but it will be a new use.

1. The easiest way to get an Object object instance as follows

var obj = new Object ();

Description: At this point the new keyword did the most useful thing is that all methods inherited Object.prototype on this you can go to look at the list of methods es5 reference in the Object.prototype. This means that at this time the object obj can use all methods inherited it!

2. However, the constructor is new model allows us to have a deeper understanding!

function Person (name, age) {
    this.name = name;
    this.age = age;
    this.sayName = function () {
        console.log (this.name);
var person1 = new Person ( "wang", 23);
var person2 = new Person ( "jiang", 24);
var person3 = new Person; // When the time does not pass parameters


It is easy to know that each instance constructor alone get a property and methods. But this is how to achieve out of it?

new process, what happens?

1) Create an object.

2). The scope constructor assigns the new object (and therefore this points to a new object)

3) Execute the constructor code (add a property to a new object)

4) Return a new object

It is noteworthy that their inheritance is: person1 / person2 / person3 inherited from Person, and Person inherited from Object (all objects are inherited from Object)

If you understand the above things, meet new programming in some simple, basic enough.

Let's continue to continue to introduce some of the new topics

3. Module mode (Moudle mode), the following explains a simple block pattern examples


var Calculator = function (eq) {
    // Here you can declare private members
    var name = 2;
    var eqCtl = document.getElementById (eq);

    return {
        // Public members exposed
        name: name,
        add: function (x, y) {
            var val = x + y;
            eqCtl.innerHTML = val;
var c1 = new Calculator ( 'eq');
var c2 = new Calculator ( 'la');
c1.name = 3; // c1 the name of the property changes, but does not affect the name of the attribute c2
console.log (c1);
console.log (c2);
c1.add (2, 2);

It is worth noting that in this Calculator constructor returns an object!

Note: If the constructor returns an object (step 4) out so new objects will be returned objects covered. The results block pattern is c1 and c2 are objects returned from a copy properties and methods, independently of each other between them.

Inheritance also changed, c1 and c2 are directly inherited from Object.
- Build their own recursive DNS server (Server)
- MySQL monitoring tool -Innotop (Database)
- Use Visual Studio to compile and use WinGDB remote debugging embedded Linux programs (Programming)
- Java threads and thread pools (Programming)
- A key installation Gitlab 7 on RHEL6.4 and Setup Mail TX (Linux)
- Ease of use "Explain Shell" script to understand Shell command (Linux)
- C ++ type conversion and RTTI (Programming)
- Mac OS X Server installation and application (Linux)
- Shilpa Nair interview experience sharing RedHat Linux package management (Linux)
- Linux kernel update error, update-initramfs: failed Solution (Linux)
- Use window.name + iframe cross-domain access to data Detailed (Programming)
- Ubuntu users how to install the latest Nvidia graphics drivers (Linux)
- Oracle metadata Reconstruction experiments (Database)
- Internal class broadcasting needs public and static (Programming)
- Sublime Text Add instructions to insert the current time zone (Linux)
- Installation of Python2.7.10 under CentOS 6.4 (Linux)
- Port is not being used, how will bind failure? (Server)
- Set up MySQL master and slave servers under Ubuntu 14.04 (Server)
- How to install GIMP 2.8.16 in Ubuntu 16.04,15.10,14.04 (Linux)
- Linux Getting Started tutorial: Experience KVM Virtual Machine chapter (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.