ALL


  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,917 0       JAVASCRIPT ARRAY PUSH