/flash/src/js/utils.js
http://echo-nest-remix.googlecode.com/ · JavaScript · 31 lines · 28 code · 3 blank · 0 comment · 8 complexity · fe355c14c266c154701f0f4c93a355b7 MD5 · raw file
- function extend(destination, source) {
- for (var property in source) {
- destination[property] = source[property];
- }
- return destination;
- }
- Array.prototype.sum = function() {
- var result = 0;
- for (var i = 0; i < this.length; i++) {
- result += this[i];
- }
- };
- if (!Array.prototype.indexOf) {
- Array.prototype.indexOf = function(elt /*, from*/) {
- var len = this.length >>> 0;
- var from = Number(arguments[1]) || 0;
- from = (from < 0) ? Math.ceil(from) : Math.floor(from);
- if (from < 0) {
- from += len;
- }
- for (; from < len; from++) {
- if (from in this && this[from] === elt) {
- return from;
- }
- }
- return -1;
- };
- };