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.