41
votes
8answers
183k views

Array functions in jQuery

I am using jQuery in my web application. I want to use arrays, but I am not able to find out functions for arrays (add, remove or append elements in array) in jQuery. Is there any link related to ...
39
votes
4answers
1k views

A function is larger than an array?

A friend of mine discovered some interesting behaviour in some Javascript code, which I decided to investigate further. The comparison (function (x) {return x*x;}) > [1,2,3] returns true in ...
24
votes
10answers
6k views

Sizeof an array in the C programming language?

why isn't the size of an array sent as a parameter the same as within main? #include <stdio.h> void PrintSize(int p_someArray[10]); int main () { int myArray[10]; printf("%d\n", ...
22
votes
2answers
14k views

Passing an Array as Arguments, not an Array, in PHP

I seem to remember that in PHP there is a way to pass an array as a list of arguments for a function, dereferencing the array into the standard func($arg1, $arg2) manner. But now I'm lost on how to ...
19
votes
9answers
4k views

Why doesn't C++ support functions returning arrays?

Some languages enable you to just declare a function returning an array like a normal function, like Java: public String[] funcarray() { String[] test = new String[]{"hi", "hello"}; return ...
19
votes
3answers
20k views

Passing an array as a function parameter in JavaScript

i'd like to call a function using an array as a parameters: var x = [ 'p0', 'p1', 'p2' ]; call_me ( x[0], x[1], x[2] ); // i don't like it function call_me (param0, param1, param2 ) { // ... } ...
18
votes
4answers
918 views

Why isn't a function's arguments object an array in Javascript?

Since it seems like the first thing people do is convert arguments into a real array, I'm interested in why the Javascript language authors and implementers decided, and continue to think, that ...
15
votes
7answers
46k views

c++ return array in a function

I have an array int arr[5] that is passed to a function fillarr(int arr[]): int fillarr(int arr[]) { for(...); return arr; } How can I return that array? How will I use it, say I returned ...
14
votes
5answers
3k views

Why can't we pass arrays to function by value?

Apparently, we can pass complex class instances to functions, but why can't we pass arrays to functions?
13
votes
2answers
178 views

Why can't C functions return arrays? What was the rationale in the language design? [closed]

I am a beginning programmer and know little about C. One thing I know but have not had explained to me is why functions can't return arrays. This is easily circumvented (Return a 2d array from a ...
12
votes
4answers
15k views

Javascript Array of Functions

var array_of_functions = [ first_function('a string'), second_function('a string'), third_function('a string'), forth_function('a string') ] array_of_functions[0]; That does not ...
12
votes
2answers
14k views

PHP get all arguments as array?

Hey, I was working with a PHP function that takes multiple arguments and formats them. Currently, I'm working with something like this: function foo($a1 = null, $a2 = null, $a3 = null, $a4 = null){ ...
12
votes
4answers
178 views

Call a function from javascript array

I have this code: var foo = { x: 2, bar: function() { alert(this.x); } }; Why does foo.bar() alert 2 while [foo.bar][0]() alerts undefined?
11
votes
4answers
9k views

PHP append one array to another (not array_push or +)

How to append one array to another without comparing their keys? $a = array( 'a', 'b' ); $b = array( 'c', 'd' ); At the end it should be: Array( [0]=>a [1]=>b [2]=>c [3]=>d ) If I use ...
10
votes
17answers
1k views

PHP: Can I reference a single member of an array that is returned by a function?

any idea how if the following is possible in PHP as a single line ?: <?php $firstElement = functionThatReturnsAnArray()[0]; ... It doesn't seem to 'take'. I need to do this as a 2-stepper: ...

1 2 3 4 5 58
15 30 50 per page