Three methods for executing ls source code

Source: Internet
Author: User

Method 1: Use eval ()

The eval () function is often used to calculate the expression. It converts the expression into a variable name or object name, and then uses it to access the variable or object.

The data in LS is stored as strings. When the string data is obtained (the string converted from JSON data ),

Storage = eval ("(" + Data + ")"); // the resulting data is a JSON string.

Note: When the JSON conversion cost is stored, You need to convert the JSON string: JSON. stringify (data). In this case, the JSON string is obtained. ,

 

Method 2: Use new function ()

Storage = (new function ("", "Return" + Data ))();

 

Method 3: insert the source code into a script tag and insert the script tag to the page number.

Because the obtained ls data returns a string, the string is created.

Document. Write ("<SCRIPT>" + Data + "</SCRIPT> ")

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.