Seven JS basics-Basic Knowledge

Source: Internet
Author: User
This article mainly introduces seven basic JS knowledge. For more information, see 1. How to add attributes to an object?
Method 1: var B = {};
B ["name"] = "test ";
Delete B. name: delete Object Attributes
Method 2: B. name = "test ";
2. How do I determine whether a variable is declared?
Typeof (a) = "undefined"
Typeof (d) = "function" is a function?

3. How is it represented as a string?
Double quotation marks (""), single line number (''), backslash (//)
1 + "1" = 11
1 + '1' = 11
4. Javascript has only one numeric type, that is, number.
5. What is the basic data type of Javascript?
Number (number), string (string), Boolean (Boolean), undefined (undefined), Null (Null)
In addition, Object)

6. What is the difference between a class and an object? How to implement it using javascript?

The Code is as follows:


Function myClass ()
{}

MyClass. prototype. ID = 1;
MyClass. prototype. Name = "johnson ";
MyClass. prototype. showMessage = function ()
{
Alert ("ID:" + this. ID + "Name:" + this. Name );
}

Var obj1 = new myClass ();
Obj1.showMessage ();


7. How many different types of loops exist in JavaScript?
. For Loop and while loop.

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.