JavaScript study notes 02 [basic-objects (Function, Array, Date, Math, RegExp, Global)]

  1. JavaScript study notes 01 [basic-introduction, basic grammar, operators, special grammar, flow control statements]
  2. JavaScript study notes 02 [basic-objects (Function, Array, Date, Math, RegExp, Global)]

table of Contents

06 JavaScript_Object

JavaScript_Object_Function

JavaScript_Object_Array

JavaScript_Object_Date

JavaScript_Object_Math

JavaScript_Object_RegExp1

JavaScript_Object_RegExp2

JavaScript_Object_RegExp3

JavaScript_Object_Global


06 JavaScript_Object

JavaScript_Object_Function

Function: function (method) object
    1. Create:
        1. var fun = new Function(formal parameter list, method body); // forget it
        2. function method name (formal parameter list) {                 method body             }

        3. var method name = function (formal parameter list){                 method body            }     2. method:


    3. Attribute:
        length: represents the number of formal parameters
    4. Features:
        1. The method definition is that the type of the formal parameter does not need to be written, and the return value type is not written.
        2. A method is an object. If a method with the same name is defined, it will be overwritten.
        3. In JS, method invocation is only related to the name of the method, not the parameter list.
        4. In the method declaration, there is a hidden built-in object (array), arguments, which encapsulate all the actual parameters.
    5. Call:
        method name (actual parameter list);

 

JavaScript_Object_Array

Array: Array object
    1. Create:
        1. var arr = new Array(element list);
        2. var arr = new Array(default length);
        3. var arr = [element list];
    2. Method
        join(parameter): Concatenate the elements in the array into a string according to the specified separator.
        push() adds one or more elements to the end of the array and returns the new length.
    3. Attribute
        length: the length of the array
    4. Features:
        1. In JS, the type of the array element is variable.
        2. In JS, the length of the array is variable.

 

 

 

 

 

 

JavaScript_Object_Date

Date: Date object
    1. Create:
        var date = new Date();

    2. Method:
        toLocaleString(): Returns the time local string format corresponding to the current date object.
        getTime(): Get the millisecond value. Returns the difference in milliseconds between the current time described by the expected object and the zero o'clock on January 1, 1970.

 

 

 

 

 

JavaScript_Object_Math

Math: Math object
    1. Creation:
        * Features: Math object does not need to be created and used directly. Math.method name();

    2. Method:
        random(): returns a random number between 0 and 1. With 0 without 1
        ceil(x): Round up the logarithm.
        floor(x): Round down the logarithm.
        round(x): Round the number to the nearest integer.
    3. Attribute:
        PI

 

 

 

Take a random integer between 1 and 100

  1. Math.random() generates random numbers: range [0,1) decimal
  2. Multiply by 100 --> [0,99.9999] decimal
  3. Discard the decimal part: floor --> [0,99] integer
  4. +1 -->[0,99] integer [1,100]

 

 

 

JavaScript_Object_RegExp1

2. Regular objects:
    1. Create
        1. var reg = new RegExp("regular expression");
        2. var reg = /regular expression/;
    2. Method
        1. test (parameter): verify whether the specified string Comply with regular definition

 

 

 

 

 

 

 

JavaScript_Object_RegExp2

 

 

 

 

JavaScript_Object_RegExp3

 

 

 

JavaScript_Object_Global

Global
    1. Features: Global object, the method encapsulated in this Global can be called directly without an object. Method name();
    2. Method:
        encodeURI(): url encoding
        decodeURI(): url decoding

        encodeURIComponent(): url encoding, more encoded characters
        decodeURIComponent(): url decoding

        parseInt(): Convert a string to a number
            * Determine whether each character is a number one by one, until it is not a number, convert the previous number part to number
        isNaN(): Determine whether a value is NaN
            * NaN The six parents don’t recognize it, not even oneself recognize. NaN participated == compare all ask false

        eval(): speaks JavaScript strings and executes them as script code.
    3. URL encoding
       Chuanzhi podcast = %E4%BC%A0%E6%99%BA%E6%92%AD%E5%AE%A2

 

Combing your hair and strengthening your brain: Su Shi, a famous writer in Song Dynasty, regarded combing his hair as a "sleeping medicine." He said: “Comb your hair for more than a hundred, lie down and sleep until you sleep well.” Combing your hair can refresh your mind, relieve fatigue, improve thinking ability and work efficiency, and prevent insomnia, neuropathic headaches and hair loss. The medical book "Theories on the Sources of Diseases" says: "A thousand times to comb your hair, your head is not white." There is an old Chinese saying that "combs hair and washes feet is better than taking a tonic." The health benefits of combing can be seen. Traditional Chinese medicine believes that the human head is "all the suns meet, and all the pulses are connected." The important meridians of the human body, more than 40 large and small acupuncture points, and more than a dozen special stimulation areas are gathered on the head. These meridians and acupuncture points play the role of running qi and blood, nourishing the whole body, resisting external evils, and communicating up and down. Regular combing and massaging of these acupoints can speed up the blood circulation at the roots of the hair, strengthen the roots, and darken the hair color, thereby dredging the meridians, smoothing the blood, calming the mind and resuscitating, and playing the functions of ears and eyes, refreshing the brain, and health care. Combing my hair frequently has a very good effect on restoring brain power. I also comb my hair every day for health maintenance. I bought a green sandalwood comb and I comb it several hundred times a day. Since I insisted on combing my hair, I found that my hair roots have become stronger, and almost seldom lose hair. Combing hair also has a good effect on insomnia and dreaminess. This method is simple and easy to do, but you insist on it. When you enjoy it , The effect will naturally appear.

Buddhism opens wisdom: The development of wisdom by Buddhism is really incredible. As long as you go deep into the sutras, wisdom is bound to be infinite. From precepts to concentration, from concentration to generate wisdom. According to the words of Master Zun: Open the wisdom of the Shura and become the Buddha. Enlightenment of the Noumenon has a thorough understanding of the nature. The nature is originally without evil or good. There is no doubt that studying Buddhism can give you the great wisdom of the universe. I have Shurangama Mantra and Great Compassion Mantra in my morning class. I keep reading every day. I also recite the Amitabha name every day. The blessings of Buddhism are incredible. Buddhism is a religion and super religion, philosophy and super philosophy, science and super science. Again, practicing Dharma is the greatest blessing in life! Studying Buddhism can quickly open up wisdom, and Buddhism can also guide your life well, allowing you to learn gratitude, become more tolerant and open-minded, and live a happier life. Brothers who have decreased mental power can try to study the Dharma, recite the Buddha, chant mantras, read the scriptures, and their mental power will also improve a lot. Buddhism is a good medicine for curing physical and mental illnesses. If you miss this medicine, it will be a big loss! It is hard to find a person, Buddhism is hard to find, good knowledge hard to find, and it is hard to make a living in China. Cherish it! Come on!

Guess you like

Origin blog.csdn.net/weixin_44949135/article/details/113743896