Prototype: Difference between revisions
Jump to navigation
Jump to search
Created page with 'http://www.prototypejs.org/api == Array == iterate over an array: <source lang="javascript"> myArray.each(function(item) { // Your code working on item here... }) // notice …' |
(No difference)
|
Latest revision as of 23:01, 31 January 2011
http://www.prototypejs.org/api
Array
iterate over an array:
myArray.each(function(item) {
// Your code working on item here...
}) // notice placement of parens
append to an array:
myArray.push(newValue)
Hash
iterate over a hash:
myHash.each(function(pair) {
// do something with pair.key and pair.value
}) // notice placement of parens
String
interpolate text:
"#{animals} on a #{transport}".interpolate({ animals: "Pigs", transport: "Surfboard" });
//-> "Pigs on a Surfboard"