Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- internal function



  this in JavaScript

this is a keyword in JavaScript. It refers to an internal object created automatically when a function executes, it can only be used in a function. For example:        function test(){     this.x = 1;   }The this keyword will change when a function is called in different situations. However, the general rule is : this refers to the object which calls the function.Next we discuss the use of this in 4 different situatio...

   this,keyword,use,JavaScript     2012-05-05 12:47:37

  How does PHP session work?

This article is about how PHP session works internally. Below are the steps : 1. Session in PHP is loaded into PHP core as an extension, we can understand it as an extension. When session extension is loaded, PHP will call core functions to get the session save_handler, i.e interface or functions for reading and writing session data. By default, PHP will handle session data by writing and reading files on the server. But PHP also supplies custom methods for handling session data, we can use sess...

   PHP, session, mechanism     2012-12-28 13:36:49

  What Makes A Successful Cryptocurrency?

The cryptocurrency landscape today is a little bit of a maze. There seem to be countless cryptos available — thousands of them, by some estimates — and unless you’re particularly well versed in this technology, it can be difficult to tell what differentiates them. To cut through some of the confusion, we decided to take a closer look at cryptocurrencies. We won’t simply list the most prominent ones, the way so many sites already have. Instead, we’re going to look i...

   BITCOIN,CRYPTOCURRENCY     2020-08-25 05:13:22

  Understand this in JavaScript

In JavaScript, this is always pointing to the owner of a function or a method. Function Let's check out function first. function introduce() {      alert("Hello, I am Laruence\r\n"); } For this function, what does this point to? In JavaScript, a global function's owner is the current page, i.e, the window object. Because its a method of the window object if we define a global function. Now you should know the this will point to the window object in the above function. ...

   JavaScript,this,event,call     2013-04-03 04:10:03

  Name resolution order in JavaScript

To understand what value a variable has in JavaScript, we need to understand some concepts such as scope and name resolution order. JavaScript has two scopes; one is program level and the other one is function level. Unlike in C,C++ or Java, JavaScript has no block level scope. So a variable defined in a if block will still be available outside. For example, the below example: var foo = 1; function bar() { if (true) { var foo = 10; } alert(foo); } bar(); The alert will display 10 since the ...

   JavaScript,Scope,Name resolution     2013-07-10 01:29:28

  JavaScript: Private variables

The first thing you often hear when talking about JavaScript is often “JavaScript doesn’t have visibility modifiers, hence it doesn’t support private variables”. This is only valid for 50%, because JavaScript indeed doesn’t have visibility modifiers (public, private, friend) but it has closures and function scopes. With these tools we can make variables private. Let’s take the following function: var names = ["Kenneth", "John", "Marc", "Robert"]; var lookup =...

   JavaScript,private variable,closure     2012-04-28 11:46:34

  The hidden risk of passing slice as function parameter

In Go's source code or other open source libraries, there are lots of cases where a slice pointer is passed to function instead of slice itself. This brings up a doubt why not passing slice directly as its internal is backed by an array pointer to point to underlying data? For example, in log package, the formatHeader function takes a parameter buf as type *[]byte instead of []byte. func (l *Logger) formatHeader(buf *[]byte, t time.Time, file string, line int) {} Let's understand the r...

   GOLANG,SLICE,SLICE POINTER     2020-12-13 06:11:14

  JavaScript: Passing by Value or by Reference

In JavaScript, we have functions and we have arguments that we pass into those functions. But how JavaScript handles what you’re passing in is not always clear. When you start getting into object-oriented development, you may find yourself perplexed over why you have access to values sometimes but not other times. When passing in a primitive type variable like a string or a number, the value is passed in by value. This means that any changes to that variable while in the function are com...

   JavaScript,Function,Pass by reference,Pa     2011-07-28 11:05:25

  New function signal.NotifyContext in GoLang 1.16

os/signal package in GoLang may not be frequently used but it provides some good features like Shutdown() which can be used to gracefully shutdown a running HTTP server. func (srv *Server) Shutdown(ctx context.Context) error With this function, there is no need to use third party library to gracefully shutdown HTTP server. How is it being used? package main import ( "context" "fmt" "net/http" "os" "os/signal" "time" ) func main() { server := http.Server{ Addr: ":8080", } http.Handl...

   GOLANG,NOTIFYCONTEXT,GRACEFUL SHUTDOWN     2021-06-19 01:07:10

  A Javascript When Function

function when(conditionFunc, execFunc, interval){ if (conditionFunc()){ execFunc(); }else{ setTimeout(function(){ when(conditionFunc, execFunc, interval);}, interval); } } You have some code which should only execute when a condition is true. E.g. You have code which relies on a javascript library but can't be sure the library has loaded yet and don't want the code to execute until it has. This is common if you have a bookmarklet which injects more than one <...

   JavaScript,When,Implementation,When function     2012-02-24 05:08:34