"Hungry big front node. JS Advanced Tutorial"-javascript basic problem-Reference delivery

Source: Internet
Author: User

"Hungry big front node. JS Advanced Tutorial" Address: Https://github.com/ElemeFE/node-interview

1. How to write a copy function of a JSON object

function Clone (obj) {

var result;

if (Array.isarray (obj)) {

result = [];

Obj.foreach (item) = {

Result.push (Clone (item));

});

} else if (typeof obj = = = ' object ') {

result = {};

for (key in obj) {

Result[key] = Clone (Obj[key]);

}

} else {

result = obj;

}

return result;

}

If it's a date or a regexp type, it has to be judged.

The difference between 2.== and = = =

= = is equal on both sides, = = = is equal to not only the value equal type

3. [1] == [1] Yes true or nofalse

Do not think, it must be false, because it is a reference type, the comparison is the address;

"Hungry big front node. JS Advanced Tutorial"-javascript basic problem-Reference delivery

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.