Jump to content

JavaScript/Glossary

From Wikibooks, open books for an open world



We try to keep consistency within the Wikibook when using technical terms. Therefore here is a short glossary.

objectAn object is an associative array with key-value pairs. The pairs are called properties. All data types are derived from object - with the exception of primitive data types.
propertyA key-value pair that is part of an object. The key part is a string or a symbol, the value part is a value of any type.
dot notationThe syntax to identify a property of an object using a dot: myObject.propertyKey
bracket notationThe syntax to identify a property of an object using brackets: myObject["propertyKey"]
curly braces notationThe syntax to express an object 'literaly' using { }: const myObject = {age: 39}
functionA function is a block of code introduced by the keyword function, an optional name, open parenthesis, optional parameters, and closing parenthesis.
functiongreeting(person){return"Hello "+person;};

The above function is a named function. If you omit the function name, we call it a anonymous function. In this case, there is an alternative syntax by using the arrow syntax =>.

function(person){// no function namereturn"Hello "+person;};// 'arrow' syntax. Here is only the definition of the function.// It is not called, hence not running.(person)=>{return"Hello "+person;};// or:(person)=>{return"Hello "+person};// assign the definition to a variable to be able to call it.letx=(person)=>{return"Hello "+person};// ... and execute the anonymous function by calling the variable// that points to it: x(...)alert(x("Mike"));// interesting:alert(x);// execute an anonymous function directly((person)=>{alert("Hello "+person);})("Mike");
methodA method is a function stored as a key-value pair of an object. The key represents the method name, and the value the method body. A method can be defined and accessed with the following syntax:
letperson={firstName:"Tarek",city:"Kairo",show:function(){returnthis.firstName+" lives in "+this.city;},};alert(person.show());
callback functionA function that is passed as an argument to another function.
consoleEvery browser contains a window where internal information is shown. It's called the console and normally not opened. In most browsers, you can open the console via the function key F12.
itemA single value in an array. Same as 'element'.
elementA single value in an array. Same as 'item'.
parameterWhen defining a function, variables can be declared in its signature, e.g.,: function f(param1, param2). Those variables are called parameters.
argumentWhen calling a function, variables can be stated to be processed in the function, e.g.,: f(arg1, arg2). Those variables are called arguments. The arguments replace the parameters which were used during the function definition.
close