Javascript console. Log () Usage

Source: Internet
Author: User
// Variable
VaR I = 'I am a string ';
Console. Log ('variable: ', I );

// Array
VaR arr = [1, 2, 4, 5];
COnsole. Log('Array: ', arr );

// Object
VaR obj1 = {
Key1: 'value1 ',
Key2: 'value2 ',
Key3: 'value3'
};
VaR obj2 = {
Key6: 'value4 ',
Key5: 'value5 ',
Key4: 'value6'
};
VaR obj3 = {
Key9: 'value7 ',
Key8: 'value8 ',
Key7: 'value9'
};

Console. Log ('object: ', obj1 );
// Object Array
VaR objarr1 = [obj1, obj2, obj3];
VaR objarr2 = [[obj1], [obj2], [obj3];

Console. Log ('object array 1: ', objarr1 );
Console. Log ('object array 1: ', objarr2 );

 
/*
Output:
Variable: I am a string
Array: [1, 2, 3, 4, 5]
Object: object {key1 = "value1", key2 = "value2", key3 = "value3 "}
Object array 1: [object {key1 = "value1", key2 = "value2", key3 = "value3"}, object {key6 = "value4", key5 = "value5 ", key4 = "value6"}, object {key9 = "value7", key8 = "value8", key7 = "value9"}]
Object array 1: [[object {key1 = "value1", key2 = "value2", key3 = "value3"}], [object {key6 = "value4 ", key5 = "value5", key4 = "value6"}], [object {key9 = "value7", key8 = "value8", key7 = "value9"}]
*/

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.