JavaScript in usage Introduction

Source: Internet
Author: User

<! DOCTYPE html>//for-in are typically used to traverse an object, or to iterate over an array        //var obj = {        //Name: "Xiaoming",        //Age:8        // };        //For (var k in obj) {        ////Use the dot operator here, you cannot get to the corresponding value:        ////. Role: Access the properties of an object        //Console.log ("key is:" + K + ", value is:" + obj[k]);        // }        //var arr = [1, 3, 5];        //For (var k in arr) {        //Console.log ("key is:" + K + ", value is:" + arr[k]);        // }        //In operator function:        //is to determine whether the property exists in the object, and if so, the return value is: True        //If it does not exist: false        //syntax: Properties in Object        //var obj = {        //name1: "Jack",        //Age:9,        //abc:undefined        // };        //for Name, Note: Window has the Name property        //Console.log ("name1" in obj);//True        //Console.log ("age" in obj);        //Console.log ("age123" in obj);        //if the member exists in the object or is a member of the prototype, the result returned is true        //Console.log ("toString" in obj);        //Console.log (obj.tostring ());        //Console.log ("abc" in obj);        //The in operator determines the array        //for arrays, the index number is the attribute        vararr = [1]; //Console.log ("1" in arr);//False        //Console.log ("0" in arr);//True        //console.log (0 in arr);//True        //to access the members of an array:        //You can use an array index or you can use a stringConsole.log (arr[0]); Console.log (arr["0"]); </script></body>

JavaScript in usage Introduction

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.