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

 ALL


  Understanding Slice Behavior in Go

In Go, understanding how slices behave when passed to functions is crucial for writing efficient and bug-free code. This behavior is often a source of confusion for many developers, especially those new to the language. In this article, we'll explore the difference between passing slices by value and by reference, and how it impacts the modification of slices within functions.IntroductionIn Go, slices are a fundamental data structure used to work with sequences of elements. They are essentially a view into an underlying array, providing a flexible and powerful way to manipulate collections of ...

369 0       ARRAY SLICE PASS BY REFERENCE PASS BY VALUE


  Remove duplicated elements in JavaScript array

During interviews, one frequent question asked would be something like how to remove duplicated elements in a JavaScript array and how many different ways you can think of. The interviewee would also be asked to write the code down. In real applications, normally front end would not need to handle this case since normally it would be done by backend, but still it's necessary for front end developers to know different ways of doing this.This post will share some of the common ways to remove duplicated elements in JavaScript array.1. ES6 SetIn ES6, there is a new type called Set, The&n...

2,543 0       JAVASCRIPT ARRAY DUPLICATED ELEMENT


  Undefined property or variable in JavaScript

JavaScript is a weak type language, and also you can use a variable or property where it's undefined. If we don't have correct ways to check whether a property or variable is defined, we may get unexpected results when we try to access the,. How can we check whether a property or variable is undefined?This is actually a somewhat tricky question. Let's start off with some facts about undefined and then see what kind of function is consistent with the ones we care about.JavaScript attaches types to values, not variables. Values can have type undefined; variables either exist (if declared) or the...

11,480 0       JAVASCRIPT ARRAY PROPERTY UNDEFINED


  JavaScript tips both novice and veteran developers can benefit from

In this post, we will share some less known but powerful JavaScript tips which can benefit both novice and veteran JavaScript developers.1. Truncate array with array lengthWe all know that object are passed by reference in JavaScript, but we may be bitten by this rule. Please check below example:var arr1 = arr2 = [1, 2, 3];//Change arr1arr1 = []; // arr2 will still be [1,2,3]arr1 and arr2 point to the same array [1,2,3] initially, later when arr1 repoints to [], the reference to arr2 is not changed, it will still point to [1,2,3]. But if we want both arr1 and arr2 point to [], what should we d...

14,678 0       JAVASCRIPT ARRAY PUSH


  Tips to improve JavaScript efficiency

Writing JavaScript code is tedious and error prone. You not only need to implement the necessary functions, but also need to ensure cross browser compatibility. This often causes the low efficiency of JavaScript developers. Here we recommend 12 tips you can benefit from.1. Remove array element by indexIf we want to remove one element in an array, we can use splice.function removeByIndex(arr, index) { arr.splice(index, 1);}test = new Array();test[0] = ’Apple’;test[1] = ’Ball’;test[2] = ’Cat’;test[3] = ’Dog’;alert(“Array before removing el...

5,706 1       JAVASCRIPT TIPS ARRAY


  A re-introduction to JavaScript

IntroductionWhy a re-introduction? Because JavaScript has a reasonable claim to being the world's most misunderstood programming language. While often derided as a toy, beneath its deceptive simplicity lie some powerful language features. 2005 saw the launch of a number of high-profile JavaScript applications, showing that deeper knowledge of this technology is an important skill for any web developer.It's useful to start with an idea of the language's history. JavaScript was created in 1995 by Brendan Eich, an engineer at Netscape, and first released with Netscape 2 early in 1996. It was orig...

2,288 0       JAVASCRIPT OOP ARRAY TYPES RE-INTRODUCTION


  Supercolliding a PHP array

Did you know that inserting 2^16 = 65536 specially crafted values into a normal PHP array can take 30 seconds? Normally this would take only 0.01 seconds.This is the code to reproduce it:<?php echo '<pre>';$size = pow(2, 16); // 16 is just an example, could also be 15 or 17$startTime = microtime(true);$array = array();for ($key = 0, $maxKey = ($size - 1) * $size; $key <= $maxKey; $key += $size) { $array[$key] = 0;}$endTime = microtime(true);echo 'Inserting ', $size, ' evil elements took ', $endTime - $startTime, ' seconds', "\n";$startTime = microtime(true);$array = arra...

2,561 0       PHP ARRAY HASHTABLE SLOW COLLIDING


  How big are PHP arrays (and values) really? (Hint: BIG!)

Upfront I want to thank Johannes and Tyrael for their help in finding some of the more hidden memory usage.In this post I want to investigate the memory usage of PHP arrays (and values in general) using the following script as an example, which creates 100000 unique integer array elements and measures the resulting memory usage:<?php$startMemory = memory_get_usage();$array = range(1, 100000);echo memory_get_usage() - $startMemory, ' bytes';How much would you expect it to be? Simple, one integer is 8 bytes (on a 64 bit unix machine and using the long type) and you got 100000 integers...

2,565 0       PHP ARRAY MEMORY OCCUPATION GARBAGE COLLECTION