Home > Web Front-end > JS Tutorial > Summary of 7 basic JS knowledge_Basic knowledge

Summary of 7 basic JS knowledge_Basic knowledge

WBOY
Release: 2016-05-16 16:56:49
Original
801 people have browsed it

1. How to add attributes to an object?
Method 1: var b = {};
b["name"] = "test";
delete b.name Delete the attributes of the object
Method 2: b.name = "test";
2. How to determine whether a variable is declared?
typeof(a) == "undefined"
typeof(d) == "function" whether it is a function

3. How to express it as a string?
By double quotes (""), single line number (''), backslash (//)
1 "1"= 11
1 '1'=11
4.Javascript has only one number type, that is number.
5.What are the basic data types of Javascript?
number (number), string (string), Boolean (Boolean), undefined (undefined), Null (empty)
In addition: Object (object)

6. What is the difference between classes and objects? How to implement it with javascript?

Copy code 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 are there in JavaScript?
Two kinds. for loops and while loops.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template