| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Errors/Not_a_function | [Back] [Original] |
Get to know MDN better
JavaScript "is not a function"
TypeError: Object doesn't support property or method {x} (Edge)
TypeError: "x" is not a function
TypeError
Object JavaScript (Object) map JavaScript (Array)
JavaScript
var x = document.getElementByID("foo");
// TypeError: document.getElementByID is not a function
getElementById
var x = document.getElementById("foo");
var obj = { a: 13, b: 37, c: 42 };
obj.map(function (num) {
return num * 2;
});
// TypeError: obj.map is not a function
var numbers = [1, 4, 9];
numbers.map(function (num) {
return num * 2;
});
// Array [ 2, 8, 18 ]
var Dog = function () {
this.age = 11;
this.color = "black";
this.name = "Ralph";
return this;
};
Dog.prototype.name = function (name) {
this.name = name;
return this;
};
var myNewDog = new Dog();
myNewDog.name("Cassidy"); //Uncaught TypeError: myNewDog.name is not a function
var Dog = function () {
this.age = 11;
this.color = "black";
this.dogName = "Ralph"; //Using this.dogName instead of .name
return this;
};
Dog.prototype.name = function (name) {
this.dogName = name;
return this;
};
var myNewDog = new Dog();
myNewDog.name("Cassidy"); //Dog { age: 11, color: 'black', dogName: 'Cassidy' }
2 (3 + 5) 2*(3 + 5) 2(3 + 5).
const sixteen = 2(3 + 5);
alert("2 x (3 + 5) is " + String(sixteen));
//Uncaught TypeError: 2 is not a function
*
const sixteen = 2 * (3 + 5);
alert("2 x (3 + 5) is " + String(sixteen));
//2 x (3 + 5) is 16
(helpers.js)
let helpers = function () { };
helpers.groupBy = function (objectArray, property) {
return objectArray.reduce(function (acc, obj) {
var key = obj[property];
if (!acc[key]) {
acc[key] = [];
}
acc[key].push(obj);
return acc;
},
{});
}
export default helpers;
App.js
import helpers from './helpers'
| Web Proxy Viewer | New URL | Original Page |