Javascript {} []

Someone asked me what is the difference between {} and [] within javascript.

Basically the difference is one is a key => value pair like PHP ‘{}’, and the other is just a pure array of values ‘[]’.

Here is the code.

var simplearray = ["genux","linux"];
var keyvaluearray = {"name" : "genux", "OS" : "linux"};

To access the different values, since the simple array is index by numbers 0 onwards you use the [x] notation, and the key value array you can reference the value by the name of the key like in object orientated way.


Abstract development

When developing you have to think in abstract way, because otherwise you would think in a very much single way and that would make any version upgrades bad!!!.. and costly..

e.g. if you are using something like a hash map, and since it implements a interface abstract setup, then if you did some code like

Map mapy = new HashMap<String, Integer>;

and the things like iterators etc would be implemented so the rest of your code you could do something similar to this

foreach (String st in mapy)

but if then in the future if you want to alter to a new improved hash map lets call it the FunckyHashMap, then you just need to

Map mapy = new FunckyHashMap<String, Integer>

since all of the abstraction within both the HashMap and FunckyHashMap will both use the abstract interfaces which means that the foreach code above would still work and you only need to alter one line, e.g. very abstract in the way that things are “talked” to, e.g. the methods/functions are still present and implemented but would be working on different structures within the class/object.

The abstract way of doing things, is just the way to go!!.. create interfaces/abstract classes etc.. and so you will save yourself allot of time in the future.

Function vs Method

The main difference between a function and a method is that a function can live independently of the any instance of a class, where as a method sits within a class.

That is about it, e.g. a function is

int func(int value);
int main()
  cout << funct(3) << endl;

whereas a method has to live within a class

class myclass
    int myMethod(int it);
int main()
   myclass theclass;
   cout << theclass.myMethod(4) << endl;


Just a small thing encase anyone else finds this interesting as such.. but you cannot add a set of ” ” strings together in c++ without declaring one being a string.. for example

cout << "hi" + "bye" << endl;

the error would be

error: invalid operands of types 

Why -> and not *name.type

When you are coding with pointers in c++ and you want to access the function/variable from that pointer deferenced, how come you cannot use something like below.

struct typeT{
   int value1;
typeT* tt = new typeT;

it is because the access element of the variable tt is higher in the compiler and thus it tries to equate


first, which is not a good thing because the tt has not been de-referenced and thus it is just a memory address pointer to the actual object. so you need to do


because like in maths the () will be equated first and then the access element part “.” and thus to make it easier


will change to


within the compiler.


Within kubuntu (or ubuntu derived setups) you can have a moonlight development .. aka the silverlight open source version that will run on linux.

if you install the


and also the


packages, the last one is the manual if you need some help, but the first one will allow the monodevelop development environment have the moonlight plugin which creates a project to develop silverlight applications in.

Curly brackets

It all depends on your type of coding, but I for style I do prefer to put array data within a separate part of the echo statement, for example.

$arr = array("first" => 1, "second" =>2);
echo "this is the first value " . $arr["first"];

but of course you can put the arr object within the echo statement as long as you { .. } it out, which is kinder similar to using the ” . as such,

echo "this is the second value {$arr["second"]}";

both work, but because of the array object uses the “..” for the hash key, then you will need to use the { .. }