Unfold Hierarchy number Tags Values

      JavaScript
        1  Examples
            1.1  Variable
                1.1.1  string
var stringA = "hello";
stringA += " world";
"Contains e:" + (stringA.indexOf("e") >= 0) + "   length:" + stringA.length
                1.1.2  date
"current time: " + new Date() + "\n" + 
"format yyyy/mm/dd: " + new Date('2022/11/30 10:35:32') + "\n" + 
"format mm/dd/yyyy: " + new Date('11/30/2022 10:35:32') + "\n" + 
"format yyyy-mm-dd: " + new Date('2022-11-30 10:35:32'.replace(/-/g,'/'));
                1.1.3  array
var arrayA =  [-1.2, 3.2, 15, 4.912];
arrayA[2];
                1.1.4  object
var cat1 = {color:"white", age:"15", name:"GuaiGuai"};
cat1.name
            1.2  Expressions
                1.2.1  Numeric operations
                    1.2.1.1  Euler number
Math.E
                    1.2.1.2  pi
Math.PI
                    1.2.1.3  absoluate
Math.abs(-5.611)
                    1.2.1.4  power of e
Math.exp(2)
                    1.2.1.5  square root
Math.sqrt(9)
                    1.2.1.6  cubic root
Math.pow(27,-3)
                    1.2.1.7  power
Math.pow(2,5)
                    1.2.1.8  cosine
Math.cos(0)
                    1.2.1.9  sine
Math.sin(9)
                    1.2.1.10  tangent
Math.tan(5)
                    1.2.1.11  arc tangent
Math.atan(-7.3)
                    1.2.1.12  arc cosine
Math.acos(0.5)
                    1.2.1.13  arc sine
Math.asin(0.3)
                    1.2.1.14  natural logarithm(base-e)
Math.log(6)
                    1.2.1.15  common logarithm(base-10)
// ECMAScript 6 supports while ECMAScript 5.1 not support
Math.log10(6)
                    1.2.1.16  base-2 logarithm
// ECMAScript 6 supports while ECMAScript 5.1 not support
Math.log2(6)
                    1.2.1.17  round up
Math.ceil(4.13)
                    1.2.1.18  round down
Math.floor(4.67)
                    1.2.1.19  round
Math.round(4.83)
                    1.2.1.20  trunc
Math.trunc(4.83)
                    1.2.1.21  random
Math.random()
                    1.2.1.22  maximum
Math.max(1,2,-3)
                    1.2.1.23  minimum
Math.min(1,2,-3)
                1.2.2  Strings operations
                    1.2.2.1  compare
'Hello' == 'hello' || 'a' < 'A' || 'a' != 'A'
                    1.2.2.2  replace first
"Hello World! World is yourself.".replace("World", "Feeling");
                    1.2.2.3  replace all
"Hello World! World is yourself.".replace(/World/g, "Feeling");
                    1.2.2.4  starts with
'Hello'.startsWith('h')
                    1.2.2.5  end with
'Hello'.endsWith('o')
                    1.2.2.6  subString
'Hello'.substring(2, 5)
                    1.2.2.7  char at
'hello'.charAt(2)
                    1.2.2.8  concat
'hello'.concat(' world')
                    1.2.2.9  split
'1,2,3,4'.split(',')
                    1.2.2.10  indexOf
'hello'.indexOf('e')
                    1.2.2.11  lastIndexOf
'hello'.lastIndexOf('l')
                    1.2.2.12  length
'hello'.length
                    1.2.2.13  search
var stringA = "abc1233hello";
var regexA = /3{2,}/ig;
stringA.search(regexA)
                    1.2.2.14  toLowerCase
'Hello'.toLowerCase()
                    1.2.2.15  toUpperCase
'Hello'.toUpperCase()
                1.2.3  Array operations
                    1.2.3.1  length
var arrayA =  [-1.2, 3.2, 15, 4.912];
arrayA.length
                    1.2.3.2  append
var arrayA =  [-1.2, 3.2, 15, 4.912];
arrayA.push(-47);
                    1.2.3.3  remove
var arrayA =  [-1.2, 3.2, 15, 4.912];
arrayA.pop()
                1.2.4  Boolean operations
                    1.2.4.1  string include
var stringA = "abc1233hello";
var regexA = /3{2,}/ig;
stringA.search(regexA) >= 0
                    1.2.4.2  string match
var stringA = "abc1233hello";
var regexA = /\S*3{2,}\S*/ig;
stringA.search(regexA) >= 0
                    1.2.4.3  array include
var arrayA =  ['A', 'B', 'C', 'D'];
arrayA.includes('C');
                    1.2.4.4  is number
Math.abs(2a) >= 0
                    1.2.4.5  and/or/not
var arrayA =  ['A', 'B', 'C', 'D'];
var stringA = "abc1233hello";
arrayA.includes('C') && (arrayA.length >= 8 || stringA.length < 5 || !stringA.endsWith("h"));
                1.2.5  Date operations
                    1.2.5.1  date formats
"current time: " + "\n" + 
"new Date() = " + new Date()+ "\n" + 
"new Date().getTime() = " + new Date().getTime() + "\n" + 
"new Date().toLocaleString() = " + new Date().toLocaleString()+ "\n" + 
"new Date().toGMTString() = " + new Date().toGMTString()+ "\n" + 
"new Date().toISOString() = " + new Date().toISOString()+ "\n" + 
"new Date().toUTCString() = " + new Date().toUTCString()+ "\n" + 
"new Date().toString() = " + new Date().toString()+ "\n" + 
"new Date().toJSON() = " + new Date().toJSON()+ "\n" + 
"new Date().toDateString() = " + new Date().toDateString()+ "\n" + 
"new Date().toTimeString() = " + new Date().toTimeString()+ "\n" + 
"new Date().toLocaleDateString() = " + new Date().toLocaleDateString()+ "\n" + 
"new Date().toLocaleTimeString() = " + new Date().toLocaleTimeString()
                    1.2.5.2  parse date
new Date('2022/11/30 10:35:32').toLocaleString() + "\n" + 
new Date('11/30/2022 10:35:32').toLocaleString() + "\n" + 
new Date('2022-11-30 10:35:32'.replace(/-/g,'/')).toLocaleString() + "\n" + 
new Date('2022/11/30') + "\n" + 
new Date('2022-11-30'.replace(/-/g,'/'))
                    1.2.5.3  components of date
var timeb = new Date('2022/11/30 10:35:32');
"year: " + timeb.getFullYear() + "\nmonth: " + (timeb.getMonth() + 1) + "\nday: " + timeb.getDate()
 + "\nweek day: " + timeb.getDay() + "\nhours: " + timeb.getHours()+ "\nminutes: " + timeb.getMinutes()
+ "\nseconds: " + timeb.getSeconds();
                    1.2.5.4  compare dates
new Date('2012/05/19').getTime()  > new Date('2016/05/19 09:23:12').getTime()
            1.3  Function
                1.3.1  Add style
function addStyle(style) {
    var node = document.createElement("style");        
    node.id = "mystyleid";        
    node.type = "text/css";        
    node.innerHTML = style.replace(/\n/g,"  ");        
    document.getElementsByTagName("HEAD").item(0).appendChild(node);
};
addStyle("body { background-color:black; color:#CCFF99; }");
                1.3.2  Remove node
function removeNode(id) {
    var node = document.getElementById(id);
    if ( node != null ) 
        node.parentNode.removeChild(node);
};
removeNode("mystyleid");
            1.4  html
                1.4.1  Selection
                    1.4.1.1  Select all
window.getSelection().removeAllRanges();     
var selection = window.getSelection();        
var range = document.createRange();        
range.selectNode(document.documentElement);        
selection.addRange(range);
                    1.4.1.2  Select none
window.getSelection().removeAllRanges();
                    1.4.1.3  Select node
function selectNode(id) {
    window.getSelection().removeAllRanges();     
    var selection = window.getSelection();        
    var range = document.createRange();        
    range.selectNode(document.getElementById(id));        
    selection.addRange(range);
};
selectNode("someid");
                    1.4.1.4  Current selected string
window.getSelection().toString();
                    1.4.1.5  Current selected html codes
var selectionObj = window.getSelection();        
var rangeObj = selectionObj.getRangeAt(0);        
var docFragment = rangeObj.cloneContents();        
var div = document.createElement("div");        
div.appendChild(docFragment);        
div.innerHTML;
                1.4.2  Value
                    1.4.2.1  Read Cookie
document.cookie;
                    1.4.2.2  Page height
document.documentElement.scrollHeight || document.body.scrollHeight;
                    1.4.2.3  Page width
document.documentElement.scrollWidth || document.body.scrollWidth;
                1.4.3  Operation
                    1.4.3.1  Scroll page
window.scrollTo(50,70 );
                    1.4.3.2  Set page as editable
document.body.contentEditable=true;
                    1.4.3.3  Pop information
alert("Hello");
                    1.4.3.4  confirm
confirm("Are you fine?");
                    1.4.3.5  input
prompt("Your cat");
                    1.4.3.6  open address
window.open("http://www.nlc.cn");

* Links and controls may be unresponsive when html page is editable.