Tag Archives: concatenate
Little tricks: repeating strings in Javascript & Python
How many times have you found yourself printing strings like “————-” or “===========”? I do that a lot when I have to do console.logs or if I’m working on a console application or script. Adding dividers to the output makes it more readable. Python has a very peculiar syntax for repeating strings, which consists in [...]
Little tricks: concatenating arrays in Javascript
It happens that when working with Javascript frameworks like MooTools for a long time, it’s easy to forget how to do things in plain/native Javascript. For example, concatenating arrays is an easy task thanks to the Function object method apply: var array1 = [1,2,3,4]; var array2 = [5,6,7]; array1.push.apply(array1, array2); // array1 = [1, 2, [...]
