Java Script Notes - woodyli7/woody-notebook GitHub Wiki
##语法
var cities = ["Melbourne", "Amman", "Helsinki", "NYC","Milan", "Tokyo"];
for (var i = 0; i < cities.length; i++) {
console.log("I would like to visit " + cities[i]);
}
//:Comments
var varName = data;
####Substring
"hello". substring(0, 2);
0 1 2 3 4
| | | | |
h e l l o
方法:比如要“llo”,第一个数字:数到l减一=2;第二个数字:数到o=5 — "hello". substring(2, 5) = “llo"
- Scope & Var
The var keyword creates a new variable in the current scope. That means if var is used outside a function, that variable has a global scope. If var is used inside a function, that variable has a local scope.
We can think of properties as variables associated with an object. Similarly, a method is just like a function associated with an object.