Tag:Subfunction

  • [JavaScript] scope, scope chain and closure

    Time:2021-9-8

    1. Scope A scope is a collection of accessible variables and functions. Scope can be divided into global scope and local scope. 1.1 global scope Global scope refers to the set of variables and functions defined outside the outermost function. In other words, variables and functions defined outside these outermost functions can be accessed anywhere. […]

  • Problems and three solutions of promise and traversal

    Time:2021-7-4

    Today, I came across a case in which we need to use promise to do infinite circulation then, and my brain hole suddenly opened up.The thing is, there’s a bunch of asynchronous functions, var func1 = function(callback){ setTimeout(function(){ console.log(‘foo’); typeof(callback) !== ‘function’ || callback(); }, 499); }; var func2 = function(callback){ setTimeout(function(){ console.log(‘bar’); typeof(callback) !== […]

  • JavaScript closure (from an interview question)

    Time:2020-11-25

    First look at a piece of code and come up with your own answer: for(var i=0;i<5;i++){ setTimeout(function(){ console.log(i); },1000) } console.log(i); The answer to this question is 5555555.One 5 is output immediately, and five 5 are output after 1 second. If we want to change the answer here into: 5 1 2 3 4 5.Well, […]

  • Test whether the function of postgre has its own transaction

    Time:2020-5-29

    1. Background Test whether the content written to the table by postgre’s function after raising an exception will be returned. 2. Code 2.1 first create fun1 DROP FUNCTION if EXISTS fun_test1(); CREATE OR REPLACE FUNCTION fun_test1() RETURNS Boolean AS $$ DECLARE i integer; BEGIN –Write a piece of data to the data table INSERT INTO […]