JavaScript work must Know (vi) Delete in instanceof

Source: Internet
Author: User

Inch

In determines whether the left -hand string or the property that can be converted to a string belongs to the right .

        var data = {x:1, y:4};//defines the direct object        alert ("x" in data),//true, X is a property of data        alert (1 in data),//false, 1 is the property value of data 。

  

        var arr = [4, 5, 7];//defines the direct array object        alert (0 in arr);//true, the index of the ARR array includes 0,1,2,0 is one of his [0] properties.        alert (4 in arr);//false, 4 is not his attribute.
instanceof

instanceof you want the left instance to be the type of object on the right .

        var date = new Date ();        Alert (date instanceof date),//true        alert (date instanceof Object),//true        alert (date instanceof number);// False

  

        var date = [1, 2, 3];        Alert (date instanceof Array),//true        alert (date instanceof Object),//true        alert (date instanceof number);// False    

  

Delete

Delete Deletes an object's properties

        var o = {x:1, y:2};        Alert (delete o.x); True Delete Success        alert ("x" in O);//false x is not a property of O

         var o = 2;        Alert (delete this.o);//false        y = 3;        Alert (delete this.y);//true        alert (delete this.window);//false    
Summary

Delete is a unary operator, delete cannot delete global variables built into JavaScript, or global variables with var declarations, but you can delete global variables that are not declared with Var.

JavaScript work must Know (vi) Delete in instanceof

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.