Im coding a BackboneJS example app with the following syntax
<script type="text/javascript">
var object = [];
_.extend(object, Backbone.Events);
object.on("alert", function(msg)
{
console.log("Your name is: "+msg);
});
object.trigger("alert","Sarah");
</script>
I noticed that the app works if the variable is defined like this
var object = {}
is there any difference between the two?
oh I found this example http://eloquentjavascript.net/chapter4.html
{} is used to pass JSON like this
var cat = {colour: "grey", name: "Spot", size: 46};
[] is just an array
var cat = ["color one", "color two", "color three"];
thanks