Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
var MyCountry = "trolling";
console.log(MyCountry).length;
console.log(MyCountry).substring(0, 3)
This is the error message I'm getting:
TypeError: 'undefined' is not an object (evaluating 'console.log(MyCountry).length')
You're putting .length and .substring on the result of console.log(), which is always undefined. Put them inside on the MyCountry instead.
This is what you want. You're closing your console.log() too soon both times.
var MyCountry = "trolling";
console.log(MyCountry.length);
console.log(MyCountry.substring(0, 3));
console.log() returns undefined, so you're calling .length on undefined.
If you want to log the length of MyCountry do console.log(MyCountry.length)
Also, console.log(MyCountry.substring(0, 3))
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 days ago.
Improve this question
I am trying to get the following script to work but it throws:
Uncaught ReferenceError: ZSOuput_account is not defined.
function ZSOutput_account(AccID) {
var accvar = AccID;
var urlRequest = 'https://1591725587001.contifico.com/sistema/reportes/cuentas/?pagina=1&cuenta=' + accvar + '&fecha_inicio=01/01/2022&fecha_fin=31/12/2022';
window.location.replace(urlRequest);
javascript:exportarExcel();
}
ZSOuput_account(2583907);
ZSOuput_account(2738049);
You are calling in a wrong way the function, it´s missing a ´t´ in your call
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I'm having issues with if-statement not working as I hope
const currentlyActive = response.data.find(
e =>
e.teamMemberEmail === firebase.auth().currentUser.email && e.isActive,
);
NOTE if results are false, then I am getting the follow from currentlyActive: undefined
// My issue
if (currentlyActive._id !== 'undefined' || null) {
console.log('hello')
}
console.log gives me an error:
undefined is not an object (evaluating 'activeSearch._id')
However if there is a result from currentlyActive then my console.log shows the hello message.
How do I fix the error message:
undefined is not an object (evaluating 'activeSearch._id')
when there are no result from currentlyActive?
Use optional chaining
if (currentlyActive?._id) {
console.log('hello')
}
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
So I am trying to push a new variable onto an array every time a function is called, but the console keeps returning an error for some reason.
let originalItem = {}
function storeItemById(rewriteItemId) {
let pushItem = rewriteItemId;
originalItem.push(pushItem);
console.log(originalItem);
}
So what I'm trying to do here is push the value of rewriteItemId into the array of originalItem, then log all the values assigned to originalItem to the console. I can simulate a value by typing and entering storeItemById('random value') into the console, but when I do, I get this error:
Uncaught TypeError: originalItem.push is not a function
Any help would be appreciated, and also please note that I am a novice coder. Thanks.
it seem that your trying to call push onto an Object.
this might be why your having a typeError.
ether change
let originalItem = {}
to
let originalItem = [];
You are creating object.
Instead, create array like this
let originalItem = []
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
//declare and assign
const firstName = 'bangalore'
console.log(firstName)
//reassign
firstName = 'mysore'
console.log(firstName)//type error
//redeclare
const firstName = 'chennai'
console.log(firstName)//syntax error
If JavaScript is an interpreted language because it executes code line by line and stops executing when it encounters an error, then why in my case is the type error not printed in my terminal? Instead, it skips and goes on to print syntax error?
Redeclaring is considered a syntax error, which happens as soon as the engine tries to parse the JS code. The TypeError is raised at runtime, which happens after parsing.
because you set firstName variable as const (from constant - means invariable value) and later try to reassign it. use let instead of const for this specific case
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I have created the mapWith function like this:
var mapWith=function(fn)
{
return funtion(list)
{
return Array.prototype.map.call(list,function(something){
return fn.call(this,something);
});
}
};
I use it on a function and an array:
var insertLatLong=function(obj)
{
//inserts to db...
}
var inception_cities=[{lat:35.0117,lng:135.7683},
{lat:48.8567,lng:2.3508},
{lat:-4.0500,lng:39.6667},
{lat:33.8600,lng:151.2111},
{lat:34.0500,lng:118.2500}];
var insertLocations=mapWith(insertLatLong);
insertLocations(inception_cities);
The error I get looks like this:
ReferenceError: list is not defined
at mapWith (/home/anr/Desktop/node js/mysql.js:11:17)
at Object.<anonymous> (/home/anr/Desktop/node js/mysql.js:40:21)
The error is caused because there's c missing in return funtion(list). Without it JavaScript thinks that you want to call something with name funtion. But you also want to pass list to it and since arguments are evaluated first then you get ReferenceError: it does not know what list is.