Tag:Function parameters

  • ES6 (V) — function


    function Function (function method update [default value, uncertain parameter, arrow function]) Default parameters — how to handle the default values of function parameters? ES5 ES6 Number of function parameters Rest parameter — how to deal with uncertain parameters? ES5 ES6 Spread operator (inverse operation of rest parameter) ES5 ES6 Arrow functions statement Parameters You can […]

  • Notes on regular expressions (3)


    String.replace Careful readers may find that we missed the last articleString.replaceThis is the way.String.replaceIt has more powerful usage and flexibility in JS, so it’s separated here and introduced separately. API String.replace(searchValue, replacement) String.replaceAt the same time, support regular expression or string replacement, and return a new string. Because our topic is regular expressions, the following […]

  • Flow (2) — simple syntax usage


    catalog Flow type inference Where flow type annotations are used Flow Type Annotations Type reference website Primitive type Array type Tuple types object type General writing Add optional properties Map class Mixed use Function type Function parameters Optional function parameters Rest parameter Function return Special types Literal type May type Mixed and any Mixed Any […]

  • Understanding the currification of JavaScript


    preface This article is 1454 words, and it takes about 4 minutes to read. In summary:From the perspective of beginners, this paper expounds the concept of currification in JavaScript and how to use it in work. Understand the curry of JavaScript Zhihu column: front end attacker Blog address: damonare’s personal blog Respect is better than […]

  • Using arrays as function parameters


    We all know that variables can be used as parameters of functions, Every element in the array is also a variable, so we canUse array elements as function parameters。 In addition, useArray names can also be used as arguments and formal parameters, passing the array’sFirst address。   1、 Using array elements as function arguments This […]

  • The bridge between callback and promise — promise


    Author: Huang HuangThis article is original and reprinted, please indicate the author and source Promise has been widely used since it came into being. It’s a magic tool in JavaScript. It solves the callback hell of asynchronous methods, provides us with the ability to use return in asynchronous methods, and integrates the call of callback […]

  • A promise


    A little understanding Promise is another way to write asynchronism. In my humble opinion, promise is a kind of encapsulation of callback Compared with callback, it has the following characteristics Promise saves asynchronous results and can be obtained at any time A chained call to the then method returns a new promise, avoiding a callback […]

  • 10 tips for JavaScript developers


    You may miss these very useful techniques. Translated from 10 super useful tricks for JavaScript developers, written by mahdhi rezvi. We know that JavaScript is developing at a high speed. Along with es2020, there are a lot of great features added. To be honest, you can write code in many different ways. To achieve the […]

  • Use react setstate in this way to develop a direct call expert!


    (Long time no see, title skin, content or conscience)As we all know, react realizes the management of components by managing the state, and setstate is the most basic method for changing the state. Although it is basic, it is not easy to master. This paper will make a relatively in-depth analysis of this method combined […]

  • Some key points of Python programming specification


    Some key points of Python programming specification: Dictionary read, use dict_ name.get (key) type method If the function parameter passes an instance, isinstance should be used in the function for parameter detection instead of type Do not use return or break statements in finally When the function parameter is variable, do not use the default […]

  • Add default values to Python function parameters


    Like C + +, python supports function definition with default values. However, the parameters with default values need to be placed after the function parameters. Otherwise, an error will be reported when calling, indicating that the parameters without default values are not assigned. In Python language, the asterisk (*) can be used to design a […]

  • How to use array as function parameter in shell


    Because of the need of work, we need to use shell to develop some small tools. When we use array as a function parameter, we find that only the first element of the array can be passed, and the elements behind the array cannot be passed into the function. #!/bin/bash function showArr(){ arr=$1 for i […]