Today, a major study of JS variables and data types, click the instance of the pop-up drop-down menu.
Watch the video:
https://www.bilibili.com/video/av33220712
versus
https://www.bilibili.com/video/av30841224
notes:
1.
debugging method
Use console.log () outputs the content to the commissioning stage.
2.
Variable
var str = "HelloWord";
Naming conventions:
Digital (not the beginning), uppercase and lowercase letters, underscores, $.
Naming the unspoken rules: all-caps is a constant
3.
String
Find character position str.indexOf ( "h") -> 0
Replace a field str.replace ( "Hello", "hi") -> "hiWord"
Character length str.length
4.
Digital
Rounded parseInt ( "1.23abc") -> 1
Take float parseFloat ( "1.23abc") -> 1.23
5.
Object
Syntax (1) object:
myCompter = {var
name: "My computer",
Brand: "Dell",
. price: 4888
};
Access syntax (2) object:
myCompter.price 或 myCompter["price"]
(3) can be expanded an additional keys:
myCompter.cpu="i7-7990k";
6.
array
was score = [98,76,75,33];
score[0] -> 98
// array class nested objects
var Score = [
{
name: "My Computer",
Brand: "the Dell",
. Price: 4888
},
{
name: "your computer",
Brand: "the Dell",
. Price: 5888
}
];
7. The
function may generate an object as a builder
定义:
var Compter=function(price,brand){
this.price=price;
this.brand=brand;
this.start=function(){
console.log("开机");
}
}
Call:
var = COM_1 new new Compter (1000, "Apple");
// At this point com_1 become a target, Compter similar class
Tomorrow's task: the family began making small books