JavaScript must know (vi) Delete in Instanceof_javascript tips

Source: Internet
Author: User

In

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

var data = {x:, Y:};//defines direct object
alert ("x" in data);//true, x is an attribute
alert (in data) of data;//false, is the property value of data. 
var arr = [,];//defines direct array Object
alert (in arr);//true, the index of ARR array includes,,, is one of his [] attributes.

instanceof

Instanceof wants the instance on the left to be the type of the 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 = [,,];
Alert (date instanceof Array);//true
alert (date instanceof Object);//true

Delete

Delete Deletes an object's properties

var o = {x:, y:};
Alert (delete o.x); True to delete success
alert ("x" in O);//false x is not an O property 
var o =;
Alert (delete this.o);//false
y =;
Alert (delete this.y);//true

Summary

Delete is a unary operator, delete cannot delete JavaScript-built global variables, or delete global variables with the Var declaration, but you can delete global variables without the Var declaration.

The above is a small set to introduce the JavaScript will be known will be (vi) Delete in instanceof related knowledge, hope to help everyone, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

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.