Front-end scrambled JavaScript learning Note two

Source: Internet
Author: User

1 implicit conversion rules for javascript:

If there is a Boolean type, it is converted to a numeric value for comparison.

If there is Nan, return false

If the string, then divided into three cases: the other side is a string directly compared, the other is a numeric value, then the string into a numeric value, if the other side is the object, then the object with the ToString () method to convert, and then compare. Finally, if other, return false.

If the number, if the other side is the object, with valueof () to compare, the rest return false

NULL and defined do not perform type conversions, but they are equal.

2 break and continue in javascript:

Both can jump out of the code block, but for break, it jumps out of the loop, and for continue, it just jumps out of the loop, and if the number of cycles is not reached, the loop continues.

In addition, JavaScript statements can be tagged in JavaScript, at this point:

Continue statements (with or without label references) can only be used in loops.

The break statement (without a label reference) can only be used in loops or switch.

A break statement can be used to jump out of any JavaScript code block with a label reference

3 Form Validation

JavaScript can be used to validate these input data in an HTML form before the data is sent to the server.

These typical forms of data that are validated by JavaScript are:

    • Has the user filled out the required fields in the form?
    • is the email address entered by the user legal?
    • Has the user entered a valid date?
    • Does the user enter text in the Data field (numeric field)?

4 prototype chain

In JavaScript, each object has an internal property [[prototype]], the value of the prototype can be an object, or it can be null, and if the value of the prototype is an object, then it has its own internal property [[prototype]], and so on, forming a prototype chain.

If you want to access the prototype of an element, you can pass the function getprototypeof ().

Front-end scrambled JavaScript learning Note two

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.