JavaScript Object (c)

Source: Internet
Author: User
Tags object serialization serialization tojson

Serialized object:

Object serialization: The state of an object is converted to a string, or a string can be restored to an object. Method: Json.stringify (), used to serialize, Json.parse (), to restore the object.

JSON (JavaScript Object Notation), which is the JavaScript objects notation.
var o = {x:1};

var s = json.stringify (o); S is a deep copy of O

var p = json.parse (s); P is a deep copy of S

Object method:
1,tostring ()//String that returns the value of the object. The default ToString () method does not output much useful information, and many classes have a custom ToString () method

2,tolocalstring ()//returns the localized string for this object
The 3,tojson ()///With serialization method calls the ToJSON () method. If called, the return value is the result of serialization
4,valueof ()///When JS needs to convert an object to a primitive value before calling. Especially when converting to a number.

JavaScript Object (c)

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.