What is the meaning of "literal" in the phrase object literal notation?
About "complimenting JSON": He specified it.
The "literal" part: Googling "object literal" provides two top resources: MDN and Wikipedia. To quote the latter:
In computer science, a literal is a notation for representing a fixed value in source code. Almost all programming languages have notations for atomic values such as integers, floating-point numbers, and strings, and usually for booleans and characters; some also have notations for elements of enumerated types and compound values such as arrays, records, and objects.
Basically, all syntax constructs whose use lead to a defined type can be called a literal. (E.g., a string literal, "abc"
.) It's a technical term that denotes, that "literally" writing something in this or that way leads to a certainly typed variable exclusively (in contrast to constructs, that look like something else, like array()
in PHP).
Well, in programming in general a literal is a fixed value.
Like saying var five = 5;
and using "five" in some math, just use the number 5 literally.
So in an OOP language an object literal would be something like:
var new_dog = {
name: "doggy",
good_dog: false
};
The entire thing is my object. Things between my {} are my literals. My notation is a pattern "name:value".