Reputation: 2271
When using the ajax library to create an Ajax Client Control, I have always noticed in examples that the element is passed in square brackets to the base class. What is the purpose of using square brackets please? it seems to be something general in Javascript and not directly related tot he Microsoft Ajax library. However, I cannot understand what is it's purpose.
MyComponent = function(element) {
MyComponent.initializeBase(this, [element]);
}
Upvotes: 0
Views: 142
Reputation: 340723
This is a syntax for creating an array. The code below will print a
and c
:
function fun(normal, array) {
console.info(array[0]);
console.info(array[2]);
}
fun(42, ['a', 'b', 'c']);
Upvotes: 1