I am using lodash 3.10.1 trunc method with foreach but getting
Uncaught TypeError: _.trunc is not a function
My code looks like:
_.forEach(myList, function(myListItem) {
myListItem.text = _.trunc(myListItem.text, 10);
});
Any suggestion?
trunc method in Version 3 changed to truncate in Version 4
https://github.com/lodash/lodash/issues/1930
Related
I get the error: "TypeError: arrayslice is not a function" in "const droppedArray = array.slice(n)" when my dropWhile() method calls the drop() method (below).
I'm confident that the dropWhile() method is correct - so no changes needed here.
I've tried problem solving the TypeError in the drop() method and reworking the code - but keep going in circles with this - can you tell me what is going wrong and how to fix this? I'm sure it's something simple...
drop: function(array,n){
if( n ===undefined){
var n = 1;
}
const droppedArray = array.slice(n);
return droppedArray;
},
dropWhile: function(array,predicate){
const dropNumber = array.findIndex(function(element, index){
return !predicate(element, index, array)
});
const dropArray = this.drop(dropNumber);
return dropArray;
}
I think you forgot to pass the array in your drop function:
const dropArray = drop(dropNumber); // <-- missing the array param
Should be:
const dropArray = drop(array, dropNumber);
What happens now is your drop function is trying to call slice on the index found by this row:
const dropNumber = array.findIndex(function(element, index){
Here is a fiddle to illustrate
Hello everyone i am trying to run a query as follows, but i always get "SQL ERROR: undefined"
What am i doing wrong.
db = window.openDatabase("Database", "1.0", "SQLDB", 200000);
RunQuery ("DROP TABLE IF EXISTS ARTIGOS");
function RunQuery(QueryExecute) {
db.transaction(function(transaction){
transaction.executeSql(QueryExecute,successCB,errorCB);
})
}
function errorCB(err) {
alert("SQL Error: "+err.message);
}
function successCB() {
alert("SQL OK");
}
One possibility is that the transaction.executeSql method takes a parameters array as its second argument. So to use the callbacks like you have, you may have to pass in an empty array for the parameters. e.g.:
transaction.executeSql(QueryExecute, [], successCB, errorCB);
Referenced from the Cordova docs here:
https://cordova.apache.org/docs/en/latest/cordova/storage/storage.html
I'm now using WebdriverIO and developing a web app.
these days I tried to set a date from input type="date", I got errors
invalid element state: Element must be user-editable in order to clear
it.
and found that
I could get rid of the errors by using addValue() but still the value won't be cleared by any API.
client.clearElement('#deadline')
Also get
invalid element state: Element must be user-editable in order to clear
it.
How can I remove the value from the form?
You can run in browser script to clear it
browser.execute(function () {
document.querySelector('#deadline').value = '';
}, null);
OR give it some value
var date = '2020-03-28';
browser.execute(function (date) {
document.querySelector('#deadline').value = date';
}, date);
reference: https://github.com/webdriverio/webdriverio/issues/386
A more elegant way is to create a custom command and put this piece of code inside
this one worked for me:
client.selectorExecute("#dateInput", function(inputs, value) {
// you can run over the inputs
for (var i = 0; i < inputs.length; i++) {
if (inputs[i].type == 'date') // any condition
inputs[i].value = "1973-12-09";
}
// or just do that:
inputs[i].value = "1973-12-09";
return;
})
When executing the following piece of code:
def xml = new XmlSlurper().parse(url)
title = rss.chanel.title
rss.channel.item.each {
sql.firstRow("SELECT COUNT(*) FROM news WHERE title = ? ", [it.title])
}
I get the following error:
Invalid argument value: java.io.NotSerializableException
What may cause it?
The problem was that it.title was a NodeChild object.
In order to get the serializable text of this object I had to use it.title.text(). It was quite tricky since I could use print it.title successfully
I am trying to use xquery for a project and I cannot see why this query is not working. It gives me the following error:
err:XPDY0002: undefined value for variable $skill
I am new to xquery and I am using EXIST DB as a database and I have tried using base x db and this works there perfectly. Is there anything i am missing in existdb? Any help would be appeciated.
for $endorsement in doc('/db/users.xml')/LOUser/Endorsements
for $endorsed_skill in $endorsement/Skills
let $skill := $endorsed_skill/text()
for $user in doc('/db/users.xml')/LOUser/User[#URL = $endorsement/URL2/text()]
let $Name := $user/Name/text()
where not($user/Skills/text() = $skill)/* I am getting the error here*/
group by
$Name, $skill
return {$Name}