Today is April 27, 2016, is also my 14th day of learning JS.
Today, I learned the main object of JS, including date, Math, String, Arry, REGEXP, and
Global and Windows.
JS Object
★date
"Automatically generate various times"
var a = new Date ();
1.a.getyear (); --→ year
2.a.getmonth (); --→ Month
3.a.getdata (); --→ Day
4.a.gethours (); When--→
5.a.getminutes (); --→ min
6.a.getseconds (); --→ sec
3.a.gettime (); --→ returns the number of milliseconds since January 1, 1970
★math
"For performing digital Tasks"
var a = 2.5;
1.math.floor (a); --→ rounding (but better than parseint performance)
2.math.round (a); --→ rounding
3.math.randow (a); Random number between--→0~1
4.math.abs (a); --→ Take absolute value
5.math.max (x, y, z);--→ returns the largest one
6.math.min (x, y, z);--→ returns the smallest one
★string
"For working with text (string)"
var a = "123";
1.☆ all strings can be seen as strings ☆
var b = a.[2]; --→b is 3
2. Replacement (replace)
var c = a.replace ("2", "two"); --→ the "2" in A to "two"
3.slice
var C = a.slice (UP); --→ the character in a where [0,2] is removed
4.substr
var c = a.substr (1,3); --a character in a where 1 is started to remove 3 characters backwards
5.split
var a = "All-in-all";
var B = A.split (","); --→ a comma as a split point, split a after the array is composed of:
[A]
★arry
"Store multiple values in a single variable"
var a = [n/a];
var b = [4,5,6];
1. Stitching Array (concat)
var C = A.concat (b); --→c for "1,2,3,4,5,6,7,8,"-Host
2. Split (join)
var c = a.join ("," a);
3. Delete (splice)
A.join (","); --→ separated by commas to form an array
4. Delete (A.splice)
A.splice (2,2);
↓ Index
★regexp (Regular)
"To retrieve the entire content"
1. Steps
(1) var a = prompt ("Please enter"); --→ the object to be retrieved
(2). var B =/^......$/; --→ Criteria for retrieval
(3) var c = B.test (a); --→ performing a match
2.[] can only choose one, () multiple selection
[ABC] [^ABC] [0-9] [A-z] [a-z] [a-z] ...
(Red|green|blue)
3. quantifiers
A*,a? , a{x,y}, A{x,}, a{x} ...
2016-04-27