Jsdelete usage (delete object attributes and variables)

Source: Internet
Author: User
Jsdelete can delete object attributes and variables. The following are some examples. If you are interested, you can see 1. Delete object attributes.

Function fun () {this. name = 'mm';} var obj = new fun (); console. log (obj. name); // mm delete obj. name; console. log (obj. name); // undefined

2. delete variables

Var name = 'lily'; delete name; console. log (name); // lily

Variables cannot be deleted directly using delelte

3. the variables in the prototype chain cannot be deleted.

Fun. prototype. age = 18; delete obj. age; console. log (obj. age) // 18

For more articles on js delete usage (delete object attributes and variables), refer to PHP!

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.