Google maps zoom parameter inside an URL not working (2015)

On September 28th a question was posted on Stackoverflow where the OP complained about the zoom parameter INSIDE HIS URL. He tried to solve the problem by specifying the zoom parameter using the letter z and the value, example: z=12 (setting the zoom parameter to 12). The problem is, this doesn’t work anymore.

In google maps v2 and even in the v3 the following link:,-90.243462&z=12 would have worked without any issue. However, for some reason the Google team decided to change it and not to allow anymore this kind of adjustment to work anymore (I must say that I’m surprised with that, I’m still not sure what was the reason for removing the documentation and functionality of the above link).

Fortunately, I found a hack on how to still use the Google maps z parameter and to get the desired result with it. Allow me to make a group of links which do not work, which work but with not getting 100% what you want.

Examples where the z parameter doesn’t work (try changing the z value to see that the parameter always holds a constant value):

Examples where the z parameter works but you do not get the pinpoint (try changing the z value to see that the parameter affects the map):

(Note: after clicking on google maps you will get a gray marker which appears and quickly disappears)

Example which works (by changing the zoom parameter the map is being affected and the red pinpoint is shown):,-90.243462&ll=38.6531004,-90.243462&z=3

The hack included adding the q attribute parameter (represents the search query) and the II attribute/parameter(represents the latitude and longitude of the map center point).

I hope this will work for at least a year from now on. If there is any issue with the link or if it doesn’t work anymore please leave a comment.

 LINK to SO question&answer

Understanding image rendering (digital image theory)

– When we come close to the TV for example, we can see the little squares. These squares are actually pixels if we then approach really close to a smartphone e.g iPhone 4s we will see that we can’t actually see these little squares or maybe we can but with trying really hard. From this, we can conclude that the iPhone has a GREATER PPI (points per inch) inch=2.54cm. So in the case of the iPhone pixels are really tiny, if talking about the TV the pixels are BIGGER! The TV doesn’t t have the equal density as the iPhone because we are watching it at greater range.

– When you are looking at TV at a close range you cannot actually see the pixels but you can see the sub pixels (group of pixels).

– The greater density of the pixels inside an image the more alive the image looks (great density-better picture).

– There exists a gap between pixels.

– Calculating the ppi (pixels per inch) –> first row * column to get the pixel size and then multiply the x inch width and y inch height and you get the area of the display . And now to get the PPI you divide the pixel size with display surface.

– Dots per inch refers to the resolution of a computer printer.

– When talking about PPI in printing 300 is outstanding, as sharp as most printers can print 100 is adequate everything below isn’t good.

All displays are made of from pixels whether it’s a laptop monitor, TV, smartphone etc… Likewise, if we can see the display in color it means that we are at least talking about rgb (red, green, blue channels) each of them has 8 bits and each channel has 2 to the power of 8 possible combinations by mixing these combinations we can get every of the 16 mil colors, also there is the argb mode where a represents a channel as well but more on that later.

Digital image is a rectangular grid of pixels  or “picture elements” it exists as an array of BYTES in the computer’ s RAM memory (this means that every array cell starting from num. 0 to array-length-1 has 1 byte inside of each cell! Important for programming. Fetching the amount of bytes can be done by using the Length property in C# for example).

Pixels are small tiny dots, rectangles or squares they can’t be physically measured and neither can be the distance between them, well it can but it’s not the case for every image that the distance between each pixel will be the same, they are considered as abstract (it doesn’t exist, well it does exist but in a digital way and can be modified and deleted).

Image resolution: refers to image quality and image size specified by the number of pixels but in fact the only attribute that counts is the number of pixels.

Pixels per centimeter (ppcm), Pixels per inch (PPI) or pixel density is a measurement of the resolution of devices in various contexts: typically computer displaysimage scanners, and digital camera image sensors. For example, a 15 inch (38 cm) display whose dimensions work out to 12 inches (30.48 cm) wide by 9 inches (22.86 cm) high, capable of a maximum 1024×768 (or XGA) pixel resolution, can display around 85 PPI in both the horizontal and vertical directions.

Important hints

  • re-sampling = pixels change
  • resizing = pixels do not change, changing the width and the height but the pixels stay the same, they group together
  • aspect ratio 16:9 in units


  • our eye can distinguish 10 mil. Colors rgb gives us more than 16 mil.
  • image compression 8×8 pixels in blocks, more is not good
  • you can resize the picture by decreasing the width and height but you can’t reverse the process, well you can but it will be blurred.
  • 720, 1080 YouTube.


Programming every day usage differences PART 1

Difference between methods and functions?

When talking about object oriented programming (OOP) then we are using methods. Methods are defined inside of classes. Every “method” defined outside of a class is called a function. Java is a typical example where functions do not exist since Java is OOP. In C++ we both have functions and methods.

Basically in OOP languages we talk about methods in languages which are not OOP we talk about functions.

Difference between parameters and arguments?

When defining a function/method we are talking about parameters if we want to use them. Once we pass data to these parameters (on function/method call) we talk about giving arguments to that function. It’s important to mention that parameters and later the arguments that we pass to the method are value types by default. In C# If we want the parameter, the method parameter to become a reference type then we have to write the keyword “ref” inside the method parameter and also when calling the method and giving arguments to it we have to specify the ref keyword.

Difference between variable post-increment and pre-increment?

Code sample:

int y;

int x = 2;

y = x++;// or y=x=(x+1) , y stores x <strong>immediately</strong> and THEN x is being incremented y=2 here

y=x;// if you would go now and write this line you would see that y=3;

// with pre-increment there is nothing much being explained

// first the value is incremented and thus it is stored in the variable y

int y;


y=++x;// y=3

I think that everything is pretty much clear with this example especially with the little equations and the comments afterwards (I wouldn’t want to repeat myself).

Difference between foreach and for loop?

In terms of performance I must quote the following (taken from stackoverflow):

Patrick Smacchia blogged about this last month, with the following conclusions:

  • for loops on List are a bit more than 2 times cheaper than foreach loops on List.
  • Looping on array is around 2 times cheaper than looping on List.
  • As a consequence, looping on array using for is 5 times cheaper than looping on List using foreach (which I believe, is what we all do).

Concerning the usage of this loops. When iterating through objects it is better to use foreach loop (it’s nicer). When working with primitive value types then use for loop. In functional programming the for loop is “everything”. Other than that it entirely depends on you. Foreach loops are massively used when iterating through objects.

Difference between explicit and implicit cast?


int i = 2;

float a = i;        // Implicit

float b = (float)i; // Explicit

I believe that the “image” above is more than enough to describe the explicit and implicit in programming. If not, then you can add the following: Implicit automatically parses the other data type and stores in in the other one if possible. An explicit casts demands additional “functions” to parse the data to the other one if possible.

Difference between structures and classes?

The main difference between classes and structures are when assigning parameters dynamically to structures (example: modifying the struct variables through a method) we can see that the value does not change! From [2] we can conclude that structures are value types. Whereas if we do the same thing with a class (trying to change a class variable through a method) we will see that the class variable will change! From [2] we can conclude that classes are reference types. Apart from that structs can’t be inherited by a another class and are used to store small amount of data inside them in particular.

Difference between private, public and protected?

Since this is the far best quick explanation online, I decided to copy and paste it and not to evaluate further.


The type or member can be accessed by any other code in the same assembly or another assembly that references it.


The type or member can only be accessed by code in the same class or struct.


The type or member can only be accessed by code in the same class or struct, or in a derived class.

SQL transactions

Once you start learning SQL, no matter which source your take to get you knowledge it is certain that you will not hear about the sql transactions. Only later, when you expand your knowledge you will see that they are pushed in as a very important concept in databases.

This is really odd. Since transactions are actually “embedded” into queries known as implicit sql transactions and are hardly mentioned anywhere when getting basic and even advanced knowledge of sql and databases. In my opinion this is not appropriate because later on you are trying to understand what transactions are but you just don’t get it because everything you can do with transactions can also  be achieved “without them”. Let’s start with some basic explanation on sql transactions, by asking ourself some questions.

What is the accepted and most used definition for an sql transaction?

“sequence of operations performed as a single logical unit of work ” source:

What are sql transactions?

A sql transaction is nothing else than sql statements (UPDATE, INSERT, DELETE, SELECT) which are encompassed within some transactional keywords (keywords are later explained). You can look at them as you look at some programming code within the curly braces in programming. For example, code which is put in a function (curly braces between the code) or a code which is put between the class curly braces.

As you can see, transactions are nothing else then pure sql statements which are used to accomplish an action against the database and to store, modify, retrieve or delete some data in the database.

Once again you can consider this equality although there are more things to it but still it is fine to express it in this way: SQL TRANSACTIONS = DATABASE DATA AFFECTED/CHANGED/MODIFIED

Why do we need sql transactions?

(Have a look to the 4 points at the end of the text before reading further explanation)

First, remember that using “plain” sql statements (UPDATE, INSERT, DELETE, SELECT) also represent transactions, the only thing is that this transactions are called implicit transactions (See types of sql transactions below).

We need sql transactions to ensure the 4 points mentioned below which are abbreviated as ACID or to expand a little bit this abbreviation:

  • Atomic – an sql transactions will pass (execute) only if every sql statements inside the transactions passes (executes). A sql transaction will fail only if one statement within the transaction fails. So, to short it out. If only one error (whatever the error is) occurs everything will be considered an error and the transactions gets rejected.
  • Consistency – implies to the changes inside the database. The change happened because of the sql transaction which was executed.
  • Isolation- means that the sql transaction is 100% independent. No prior condition has to be met in order for a transaction to happen.
  • Durability – once the sql transaction executes it stays “forever”. No matter what kind of negative event happens to the database.

I’m still not sure how can I benefit from an sql transaction?

When encapsulating sql statements in an sql transaction you can put the sql statements on “freeze”. This means  that you can execute statements when you want by applying the command COMMIT.  After that, your transaction is done and the data has changed in the database (based on the sql statements).

Now, the most valuable thing what transactions offer is that you can ROLLBACK your action! The ROLLBACK command is used if you want to undo your changes to the database. Using an sql statement without an sql transaction such as INSERT, UPDATE ect.. does not allow you to somehow reverse the changes that happened to the database.

How does an sql transaction look like?

example (mysql)

start transaction
SET Purpose='bought a new car'


example (MSSQL)

Begin Transaction
SET Purpose='bought a new car'

Commit Transaction

Which types of sql transactions exist?

There exists two types of sql transaction.

  1. Implicit sql transaction – the one that does not need any special keyword between the sql statement. It actually represents the sql statements itself.  By default an sql transaction is actually the sql statement.
  2. Explicit sql transaction – the one that needs special keywords (depends on the database itself, MySql, SqlServer) which surrounds the sql statements. Use them if you have an intention of reversing the changes which you make

When to use sql transactions?

Use them if you have multiple sql statements which are going to modify the data in the database. Don’t forget that sql transaction are nothing more than plain sql statements (implicit transactions). Based on your needs, decide whether you should use explicit or implicit sql transactions.

When to not use sql transactions?

You really don’t need to use sql transactions if you have ONE sql statements only which should go into your transaction.

What happens with an sql transaction behind the scenes?

First when you execute the sql transaction. The log file is getting info (data is written inside the log file) that a transaction will occur shortly. After that the log file get’s the actual data written to it that an sql statement is in process (executing). Finally the log file get’s the data written to it that the transaction finished.

So 3 things or states are written to the log file:

  • notifying that the transaction will occur/is about to occur
  • sql statement in progress
  • completed sql statement in the transaction

What else should I know about sql transactions?

If you start/begin an sql transaction and you do not specify the finishing command at the end (ROLLBACK COMMIT) others (other connections established) will not see the new change in the database because the data is not in this case committed yet. This rule is covered in the isolation property.

Keywords which are often used in sql transactions :


  • Atomicity: ensures that all operations within the work unit are completed successfully; otherwise, the transaction is aborted at the point of failure, and previous operations are rolled back to their former state.
  • Consistency: ensures that the database properly changes states upon a successfully committed transaction.
  • Isolation: enables transactions to operate independently of and transparent to each other.
  • Durability: ensures that the result or effect of a committed transaction persists in case of a system failure.

Sql transactions commands:

  • COMMIT – executes the transaction
  • ROLLBACK – reverses the transaction
  • SAFE-POINT – makes a safe-point on an sql statement and once your decide to rollback to a specific safe-point the data will get to the state where it was once the safe-point was created! You can look at it the way Windows System restore function: You decide to create a system restore point today and after 10 months you want to get to the state you were 10 months ago (the day you created the system restore point) You go to this program and comeback to your settings and files and programs which were installed up to that day(of-course it is not really how system restore functions, this more a idealistic example of a system restore).

Stack vs Heap

I’ve read lot of articles on-line prior on posting about this topic. I will try to combine various articles which talk about it and try to explain it in an interesting and comprehensible manner.

I believe everyone who’s starting or has programmed for some amount of time without looking at the theory too much, has heard of the term stack, the term heap is usually less heard.

After reading quite a bit of both I can say that there are words which are often misinterpreted by many programmers. I’ll try to do my best and not to make any assumptions neither to place some words in a false context.


A stack is a memory place/location where variables which a function executes (int, string, char, bool…) are stored. You can think of a box which can add variables inside and also remove them. When a function executes (we are talking here about any function which can be the main() function which is always executed when a program runs and other functions that we have defined in the code and are calling them inside the main() function) all the variables which are inside that function are stored on the stack. We say that “they are pushed onto the stack”. After the function completes, the variables inside the stack are pushed out of the stack, they are removed from it.

Every stack has a fixed location at the beginning, however this can easily change once variables start to kick in and the stack get’s bigger, the memory pointer is displaced to indicate the current extent of the stack. Remember that when new elements are added to the stack they are always placed on top that box called the stack and the old ones do not get pushed out, they are removed once the function is done with it’s execution only then is the stack freed from the variables that the function contained.

The good thing that we take for granted today is that the memory stack is managed automatically, this means that we don’t have to reserve it manually or free it once we do not need the variables anymore.

Variable scope: also all the variables that are stored on the stack are local not global. This means that the variables lifetime is temporary, after the function returns those variables are immediately destroyed as mentioned earlier.

The stack is also called LIFO (last in first out).

One last thing to mention is the stack-overflow event which can occur if the stack’s capacity get’s exceeded. After the event occurs, the programs crashes.


A heap is also a memory place/location where objects are stored. Often people use the term dynamic memory allocation (don’t think now that the stack is then also referred to as a static memory allocation, this is completely false, we will talk about this in another article). The good thing about it is that you can allocate and deallocate objects at any time and how much you want.  As you can see by now the heap is used to store bigger data sets and complex data which are objects. The heap is not arranged like the stack, we can say that the objects are thrown around randomly, you can add and remove the object whenever you want there is no top object like there is in a stack.

Variable scope: also all the variables that are stored on the heap are global not local variables. This means that the variables lifetime is not temporary.

This is pretty much it about the heap. Please read the article about the Garbage Collector to get greater knowledge on how and why are objects removed from the heap. (url:

To make a conclusion, here is a useful list  about the PROS & CONS taken from stackoverflow (url:


  • Stored in computer RAM just like the heap.
  • Variables created on the stack will go out of scope and automatically deallocate.
  • Much faster to allocate in comparison to variables on the heap.
  • Implemented with an actual stack data structure.
  • Stores local data, return addresses, used for parameter passing
  • Can have a stack overflow when too much of the stack is used. (mostly from infinite (or too much) recursion, very large allocations)
  • Data created on the stack can be used without pointers.
  • You would use the stack if you know exactly how much data you need to allocate before compile time and it is not too big.
  • Usually has a maximum size already determined when your program starts


  • Stored in computer RAM just like the stack.
  • Variables on the heap must be destroyed manually and never fall out of scope. The data is freed with delete, delete[] or free
  • Slower to allocate in comparison to variables on the stack.
  • Used on demand to allocate a block of data for use by the program.
  • Can have fragmentation when there are a lot of allocations and deallocations
  • In C++ data created on the heap will be pointed to by pointers and allocated with new or malloc
  • Can have allocation failures if too big of a buffer is requested to be allocated.
  • You would use the heap if you don’t know exactly how much data you will need at runtime or if you need to allocate a lot of data.
  • Responsible for memory leaks


Pointers (playing with pointers in C)

When I started programming (first language in use:C#) I new that pointers existed but I haven’t really had the time to tackle that field although I really wanted to, but somehow ignored that for a while. In C# I didn’t need pointers for anything, you could to everything without them. Later when I was helping my former high school colleague with C I realized that I will have to learn them one way or the other to help him better understand programming and eventually get a better grade.

I think that everyone has heard of pointers as being a really complicated field to grasp so I took extra caution when started to learn them. I must specify the link where I picked the stuff pretty quickly is really awesome and you will see immediately that the author of the article really took some time to explain them and even made a little quiz which is, again, awesome (he uses c++ but this isn’t relevant in order to understand them): Click here

Here goes my explanation on pointers:

You can think of pointers as arrows which hold an address and therefore the arrow knows where to go. Pointers point to a memory location which stores data. Bear in mind that he computer memory consist of small cells everyone having the length of 1 byte (8bits) and each cell has a unique address. REAL DEFINITION: a pointer is a variable whose value is the address of another variable (definition url: click here)

If you have ever written a decent ms office word article which involves footnotes or if you think of the Wikipedia numbers that are placed at the end of a sentence usually after the dot(.). When you click on the number it will lead you to some further explanation about the marked sentence which is at the end of the Wikipedia document (the further explanation is often accompanied by a link). the little number that you clicked on leads you to some other value in this case associated with the little clicked number. We can say that the little number contains an address which new where to point if clicked. This is exactly how pointers work. They are storing a value which is an address which leads you to another value. To make it 100% simple: they are addresses and everyone knows what addresses are for in real life.

Okay, why do we use pointers, why don’t we just directly store values inside the memory?

Before answering this question I must tell you what I always heard about pointers. Experienced programmers were always saying that pointers are fast. I’ll never forget that because that is the only thing that I’ve heard about pointers from someone else. Well, the reason why there are fast would explain their usage wouldn’t it?

So why use them?

answer: because they save memory and time.

Okay, so how do they safe memory?

Answer: remember what the real definition of pointers is? Pointers store the address of the variable which points to the storage location. Just imagine having a large chunk of data. let this big data be an array. If you want to copy this array to another array and not use pointers you would most definitely store all of the elements of the previous array to a new array rather than doing that you can use the advantage of pointers and create a pointer which will hold the address of the array thus not creating another array and consuming a lot of memory again. Also the memory is heavily connected with the time variable. When you occupy memory it definitely takes up some time. Now, think of populating memory with a lot’s of data. This would take a pretty much amount of time and you don’t want this process to happen multiple times for the same data.

Okay, so now we can see that pointers are efficient, now how do they work and how do you use them?


Example 1:

    int *p;
    int a=8;

First to clear things up for real beginners. the symbol (*) means: fetch (get) the value of the pointer p. the symbol (&) means: fetch the address of the variable which is located right after the & symbol.

So, once again value=*,  address=&

The above code has a pointer p declared after that we are storing an integer 8 in variable a. The line “p=&a” means that we are giving the address to the pointer to point! This is what pointers are for, they are always storing the address of a specified variable. We discussed that previously.

Here is a little illustration for that:

The most important thing that you have to remember here is that a pointer always points to a memory location which was defined previously by giving the address to the pointer. This means, no matter how much the value of a location changes which a pointer points to, the pointer will always get the current value of that location. Let’s say that after reserving a space (certain amount of memory) and then declaring a pointer to point to this reserved space, you can alter that location numerous amount of time and the last value specified for this location will be the value of the pointer since it point’s at it always.

See how pointers are easy actually?

Let’s put some more examples:

Example 2:

int a = 5, b = 10;
int *p1, *p2;
p1 = &a;
p2 = &b;
*p1 = 10;
printf("%d", a);

In this example, you can see that you can change the value of a variable by not only changing it to just put another value in it, like you would normally do, for example: a=3 (a variable changed to value 3). You can also modify it by putting it in a pointer *p1 = 10;. This line of code changed variable a from 5 to 10 because earlier, to be more precise at line 3 we said that p1=&a;, and by that we stored the address of a inside p1. Now, every-time we give another value to p1 we will automatically change the value of variable a.

Example 3:

int array[]={1,2,4,7,9};
int *p;
printf("%d", array[3]);

We can see that the same applies for an array as well. We’ve declared an array and a pointer p. Next we gave the variable p the address of the 4th element in the array and after that we changed it to 10 using a pointer. Now the array and index are both equal to 10 instead of 7.

This was an introduction to pointers. We mentioned their usage benefits and how to use them in code. Later articles will cover double pointers (pointers which point to pointers which then point to the value, I think you already understand double pointers), functions and pointers as arguments in a function and some more “confusing” pointers code.

Garbage collector

Taken from wikipedia, url:

“In computer science, garbage collection (GC) is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program”

The above definition says all. If you are not dealing with the actual memory in programming then I believe this is enough to know about the GC. Of course other stuff will be mentioned.

When I was answering questions in the C# section at Daniweb I often encountered the word  GC. Some users always said things like: “when the garbage collector kicks in”. This get’s us to a new question and that is, when does the garbage collector really kick in?

The garbage collector (consider it being a program) kicks in, acts, get’s in charge of things when the heap gets full. This means when there is no place left for a new object to populate the heap. Please do not take this for granted, this is just for better understanding when the garbage collector does it’s job. For more on the garbage collector and heaps generation please read the first paragraph on stack-overflow first answer: click here

In real life, We cannot and we should not predict when the garbage collector starts making the free space for new objects. You can also conclude by this that it isn’t necessary to tell the garbage collector when to start (previous to the garbage collector implementation memory had been manually deallocated).

The biggest advantage of the GC is that you don’t need to deallocate objects manually, you don’t have to worry how many objects could the user create at some time and how you should take care of them (how to free space for the new objects and which objects already in action should be pushed aside to the next generation heap).

The disadvantage of the GC is that it also takes up space,  it consumes resources and affects performance. In some previous versions of GC the problem was the so called “blockage/stalls” which meant that the GC rests, doesn’t do anything at some time which obviously isn’t good and affects performance.

Nowadays the GC tries to do as much work as possible in the background while the application runs, although the GC is much more sophisticated than before, it is still hard to maintain lot of memory taken by objects on the heap.

Just to mention that IOS does not implement a GC although being the most desirable. The claim that it affects their performance drastically.

Also there is something called as a Tracing garbage collection which represents a type of garbage collector which job is to trace the objects who will have to be removed by the main GC.

Strings, Objects (immutability)

Topic includes

  • immutability
  • literal string
  • methods/functions
  • value type
  • reference type
  • object
  • class
  • verbatim string

Today I’ll discuss what does the heading above mean and why it is important or maybe it isn’t?

When anybody starts to program the first thing that will come up to him are strings. Strings are EVERYTHING in programming, you can do whatever you like with them you can also convert other data type to strings and make some useful operations and then again convert to its primitive type ( I do that very often). At one point you will have to get familiar with the basic methods that strings provide. If you go deeper you will see that you can substitute many string operations using regex.

What does immutable mean?

If you asked a layman what does immutable mean he’ d most probably say something that cannot MUTATE (something that can not change).

I remember when I first heard this word in programming, I immediately thought of a monster who can mutate (can change its appearance, structure, look ect.). Even tough this doesn’t make sense since we want something immutable here.

I must say that I picked up the term really quickly and I understood what it meant but didn’t go deeper with my mind to it.

Enough talking for now, let’s start with an example:

var name="Paul";
name.concat(" and Jenny");

The question is, why doesn’t the literal string “&Jenny” get applied to the name, why doesn’t it change the value of name when the concat() function is applied?? The answer can be found in the title of-course, strings are immutable. This means that the variable “name” is of value type which means that it stores the data directly to the memory and access it as well.

definition of value types (source url: A data type is a value type if it holds the data within its own memory allocation.

This withdraws the reference types, strings are immutable because the are not reference type rather than that, they are value types as mentioned above.

definition of reference type (source url: A reference type contains a pointer to another memory location that holds the data.

One thing to clear up here. No matter which type of is the variable “name” the concat() function returns the result “Paul & Jenny” BUT DOES NOT APPLY IT TO THE VARIABLE NAME. It just stays there “hanging in the air”.


var name="Paul";
name.concat(" and Jenny");
alert(name.concat(" and Jenny"));

In the alert box you will see the result “Paul & Jenny” and you will wonder, how did this concatenate now, but if we print out (again showing a alert box) the variable name “Paul & Jenny” the concatenation is not applied and it does not show up? That’s because the function concat() returns the new value and the alert box just display’s it.

To make a conclusion: value types can not be altered/modified/changed. Reference types can be changed.

How do I concat my string literal to the variable string “Paul”?

The easiest solution here would be to override the variable ( replacing the variable name by applying a new content to it, see the following example)


var name="Paul";
name=name.concat("and Jenny");

The output of name will now be “Paul & Jenny”

Using a string like an array is extremely useful sometimes but the immutability kicks in and we have to write some extra code to overcome this state.


 var name="Paul";

As you can see in the output, the name remains exactly the same (although we’ve “changed” the first letter to ‘r’)By now you should know the answer why this is the case, but, just in case, strings are immutable, strings are value types hence not reference types. Na altering/modifying/changing whatsoever.

Let’s now modify the string in the way that we could not do it before, but first let’s make a small introduction to Objects.

When I started to learn objects (OOP- object oriented programming) things didn’t make sense because I always and I must says once again, always thought in this way: “Why would I use something else if I can achieve that with the previous known stuff”.

Every time someone asks me about objects, I say to him :Objects or OOP programming is used to make things more tidy, more neater.” I didn’t mention more effective, less code or anything else apart from the sentence above.

I always avoided functions/methods, classes ect. because I liked to get my things done quickly just writing the code going step by step, line by line and finding a solution without this fancy stuff which was good until bigger projects came… Then I just new that I had to involve the objects/classes (object!=class) to get my things done quicker!

I’ don’t want to go too deep into objects and classes especially not in the JavaScript sense, since JavaScript does not have a full OOP structure like C# for example, but I will say the most important part of it.

You can think of an object as a wrapper where you wrap inside your properties and functions which you later use by specifying the object name and accessing it’s properties or methods via the . symbol


var person = {
 firstName: "Paul",
 lastName : "Sanders",
 fullName : function() {
 return person.firstName+" "+ person.lastName;

You can see that we have an object which encapsulates (wraps around) properties and methods and we are accessing the method .fullName() via the . symbol (as said) and we are also able to access it because we used the object before “person”.

I will stop here with the explanation of objects, I think that this is more than enough for this post (at the end of the article you can find a short explanation of objects and classes)

Let’s get back now to reference types, why? Because we involved object in the whole story… TO BE CONTINUED…

Incredibly good links on immutability:


Adding text from div to another div atribute inside a (stackoverflow problem)

Problem posted: 07/08/2015


Problem description:

The title says it all. The user wanted to fetch the text from the div tag and assign it to the

attribute which had a parent li.

Solution to the problem:

var array=[];
$('.pin_head > div').each(function (index,obj) { 

   array[index]= $(this).text();


$('li > div').each(function (index,obj) {
    var data= $(this).attr("data-col",array[index]);

Formating characters – indentation&comma (stackoverflow problem)

Problem posted: 08/08/2015


Problem description:

Format the current string :
Landing Hits: 0Rewards Hits: 0Facebook Posts: 0Twitter Tweets: 0Twitter Autofollows: 0Instagram Photos: 0Instagram Likes: 0Instagram Votes: 0Pinterest Pins: 0Form Submissions: 0Submissions: 0Engagement: 0Views: 0Prints: 0″

to the following output:
Landing Hits: 0, Rewards Hits: 0, Facebook Posts: 0, Twitter Tweets: 0, Twitter Autofollows: 0, Instagram Photos: 0, Instagram Likes: 0, Instagram Votes: 0, Pinterest Pins: 0, Form Submissions: 0, Submissions: 0, Engagement: 0, Views: 0, Prints: 0″

The OP wanted to add a comma after the number (the number can be positive or negative greater than and lower than 0, not only 0)

Solution to the problem:

var c = "Landing Hits: -345Rewards Hits: 0Facebook Posts: 0Twitter Tweets: 034534532Twitter Autofollows: 0Instagram Photos: 0Instagram Likes: 0Instagram Votes: 0Pinterest Pins: 0Form Submissions: 0Submissions: 0Engagement: 0Views: 0Prints: 0";
var array = []
var counter = 0;
var num;
var dup = "";
for (var i = 0; i<c.length; i++) {
 dup += c[i];
 if (c[i]==":"){dup+=" ";}
 if (!isNaN(c[i]) && isNaN(c[i+1]) && c[i]!=" ") {
 dup += ", "

After that I also decided to make a function which would get the length of each number after the colon ":" in the same sequence.

var c = "Landing Hits: 345Rewards Hits: 0Facebook Posts: 0Twitter Tweets: 034534532Twitter Autofollows: 0Instagram Photos: 0Instagram Likes: 0Instagram Votes: 0Pinterest Pins: 0Form Submissions: 0Submissions: 0Engagement: 0Views: 0Prints: 0";
var array = []
var counter = 0;
var num;
var dup = "";
var i=0;
for (var j=0; j<c.length; j++)
if (!isNaN(c[j]) && c[j]!=" ") // because js interprets " " as 0 if applied on isNan() evaluates to false so I hade to include the other part inside the if as well
if (isNaN(c[j+1]))