On the difference between JSON and array

Source: Internet
Author: User

JSON and arrays all store data, but there are some differences.

Difference one: The subscript of the JSON is different from the subscript of the array, the subscript of the JSON is the string, and the subscript of the array is the number.

<script>window.onload=function() {        var json={name: ' Juce ', Age: ' 23 ' };         alert (json.age); // also equals alert (Json[age])        var arr=[' A ', ' B ', ' C '
Alert (arr[0

</script>

Difference two: JSON has no length, and array has length.

<script>    window.onload=function() {        var json={name: ' Juce ', Age: ' ~ '};        alert (json.length); // The return is undefined        var arr=[' A ', ' B ', ' C '
alert (arr.length); // the return is 3.

</script>

Difference Three: JSON is a data format, and an array is a data type, data types can be added and modified.

<script>    window.onload=function() {        var json={name: ' Juce ', Age: ' ~ '};         // alert (json.length);//Return to undefined        var arr=[' A ', ' B ', ' C '];         // alert (arr.length);//Return is 3        Alert (Arr.push (' C '))// return is 4    }</script>

For an array of methods, mention here:

Array    Internal support Array.concat ()    connection Array array.join ()    concatenate array elements to build a string Array.Length    the size of the array array.pop ()    deletes and returns the last element of the array Array.push () adds an element to the array    array.reverse ()    reverses the order of the elements in the array array.shift () moves the element to the    group Array.slice (    returns a portion of the array array.sort () sorts the array    elements Array.splice ()    inserts, deletes, or replaces elements of the arrays array.tolocalestring ()    Converts an array to a local string array.tostring () converts an    array into a string Array.unshift ()    inserts an element into the head of the array

We can consolidate it.

This is also my own some superficial understanding, there are any additions or reminders can contact the comments.

I am a rookie, but also gradually learn to understand ...

On the difference between JSON and array

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.