Facing issues in JS Filter function in IE 11
I have following lambda expression
if (MyObject.eId.filter(e => e === record.Id).length > 0)
{
return;
}
This works in all broswers except IE(checked in IE 11)
I tried to convert this to following way but getting syntax error.Please help me to rewrite above function.
MyObject.eId.filter(function (e) {
if (e === record.Id).length > 0
{
return;
}
});
javascript jquery
add a comment |
I have following lambda expression
if (MyObject.eId.filter(e => e === record.Id).length > 0)
{
return;
}
This works in all broswers except IE(checked in IE 11)
I tried to convert this to following way but getting syntax error.Please help me to rewrite above function.
MyObject.eId.filter(function (e) {
if (e === record.Id).length > 0
{
return;
}
});
javascript jquery
Maybe you want to use a polyfill? Take a look at this.
– JO3-W3B-D3V
Jan 3 at 12:41
1
For non arrow function your code should look like:if ( MyObject.eId.filter(function(e) { return e === record.Id; }).length > 0 ) {
– HMR
Jan 3 at 12:47
add a comment |
I have following lambda expression
if (MyObject.eId.filter(e => e === record.Id).length > 0)
{
return;
}
This works in all broswers except IE(checked in IE 11)
I tried to convert this to following way but getting syntax error.Please help me to rewrite above function.
MyObject.eId.filter(function (e) {
if (e === record.Id).length > 0
{
return;
}
});
javascript jquery
I have following lambda expression
if (MyObject.eId.filter(e => e === record.Id).length > 0)
{
return;
}
This works in all broswers except IE(checked in IE 11)
I tried to convert this to following way but getting syntax error.Please help me to rewrite above function.
MyObject.eId.filter(function (e) {
if (e === record.Id).length > 0
{
return;
}
});
javascript jquery
javascript jquery
asked Jan 3 at 12:39
aniltcaniltc
194118
194118
Maybe you want to use a polyfill? Take a look at this.
– JO3-W3B-D3V
Jan 3 at 12:41
1
For non arrow function your code should look like:if ( MyObject.eId.filter(function(e) { return e === record.Id; }).length > 0 ) {
– HMR
Jan 3 at 12:47
add a comment |
Maybe you want to use a polyfill? Take a look at this.
– JO3-W3B-D3V
Jan 3 at 12:41
1
For non arrow function your code should look like:if ( MyObject.eId.filter(function(e) { return e === record.Id; }).length > 0 ) {
– HMR
Jan 3 at 12:47
Maybe you want to use a polyfill? Take a look at this.
– JO3-W3B-D3V
Jan 3 at 12:41
Maybe you want to use a polyfill? Take a look at this.
– JO3-W3B-D3V
Jan 3 at 12:41
1
1
For non arrow function your code should look like:
if ( MyObject.eId.filter(function(e) { return e === record.Id; }).length > 0 ) {
– HMR
Jan 3 at 12:47
For non arrow function your code should look like:
if ( MyObject.eId.filter(function(e) { return e === record.Id; }).length > 0 ) {
– HMR
Jan 3 at 12:47
add a comment |
1 Answer
1
active
oldest
votes
Your non-arrow function is incorrect: Basically in the callback/predicate of the .filter
method, you should only check if e
matches the record ID, without checking for length. The length check should be performed on the returned/filtered array instead:
if (MyObject.eId.filter(function(e) { return e === record.Id; }).length > 0) {
return;
}
To break down the complicated one-liner above, you can see it as this:
// Step 1: Get an filtered array of IDs that match record ID
var filteredIds = MyObject.eId.filter(function(e) {
return e === recordId;
});
// Step 2: Check length of filtered array
if (filteredIds.length) {
return;
}
1
This should be the accepted answer due to compatibility.
– BRO_THOM
Jan 3 at 12:56
It showing an error in step1
– aniltc
Jan 3 at 12:58
if (MyObject.eId.filter(function(e) { return e === record.Id }).length > 0) This works fine
– aniltc
Jan 3 at 13:05
1
@aniltc Sorry, had a minor typo: should befunction
notfuntion
. Fixed it now.
– Terry
Jan 3 at 13:08
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54022483%2ffacing-issues-in-js-filter-function-in-ie-11%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your non-arrow function is incorrect: Basically in the callback/predicate of the .filter
method, you should only check if e
matches the record ID, without checking for length. The length check should be performed on the returned/filtered array instead:
if (MyObject.eId.filter(function(e) { return e === record.Id; }).length > 0) {
return;
}
To break down the complicated one-liner above, you can see it as this:
// Step 1: Get an filtered array of IDs that match record ID
var filteredIds = MyObject.eId.filter(function(e) {
return e === recordId;
});
// Step 2: Check length of filtered array
if (filteredIds.length) {
return;
}
1
This should be the accepted answer due to compatibility.
– BRO_THOM
Jan 3 at 12:56
It showing an error in step1
– aniltc
Jan 3 at 12:58
if (MyObject.eId.filter(function(e) { return e === record.Id }).length > 0) This works fine
– aniltc
Jan 3 at 13:05
1
@aniltc Sorry, had a minor typo: should befunction
notfuntion
. Fixed it now.
– Terry
Jan 3 at 13:08
add a comment |
Your non-arrow function is incorrect: Basically in the callback/predicate of the .filter
method, you should only check if e
matches the record ID, without checking for length. The length check should be performed on the returned/filtered array instead:
if (MyObject.eId.filter(function(e) { return e === record.Id; }).length > 0) {
return;
}
To break down the complicated one-liner above, you can see it as this:
// Step 1: Get an filtered array of IDs that match record ID
var filteredIds = MyObject.eId.filter(function(e) {
return e === recordId;
});
// Step 2: Check length of filtered array
if (filteredIds.length) {
return;
}
1
This should be the accepted answer due to compatibility.
– BRO_THOM
Jan 3 at 12:56
It showing an error in step1
– aniltc
Jan 3 at 12:58
if (MyObject.eId.filter(function(e) { return e === record.Id }).length > 0) This works fine
– aniltc
Jan 3 at 13:05
1
@aniltc Sorry, had a minor typo: should befunction
notfuntion
. Fixed it now.
– Terry
Jan 3 at 13:08
add a comment |
Your non-arrow function is incorrect: Basically in the callback/predicate of the .filter
method, you should only check if e
matches the record ID, without checking for length. The length check should be performed on the returned/filtered array instead:
if (MyObject.eId.filter(function(e) { return e === record.Id; }).length > 0) {
return;
}
To break down the complicated one-liner above, you can see it as this:
// Step 1: Get an filtered array of IDs that match record ID
var filteredIds = MyObject.eId.filter(function(e) {
return e === recordId;
});
// Step 2: Check length of filtered array
if (filteredIds.length) {
return;
}
Your non-arrow function is incorrect: Basically in the callback/predicate of the .filter
method, you should only check if e
matches the record ID, without checking for length. The length check should be performed on the returned/filtered array instead:
if (MyObject.eId.filter(function(e) { return e === record.Id; }).length > 0) {
return;
}
To break down the complicated one-liner above, you can see it as this:
// Step 1: Get an filtered array of IDs that match record ID
var filteredIds = MyObject.eId.filter(function(e) {
return e === recordId;
});
// Step 2: Check length of filtered array
if (filteredIds.length) {
return;
}
edited Jan 3 at 13:07
answered Jan 3 at 12:52
TerryTerry
30.5k44369
30.5k44369
1
This should be the accepted answer due to compatibility.
– BRO_THOM
Jan 3 at 12:56
It showing an error in step1
– aniltc
Jan 3 at 12:58
if (MyObject.eId.filter(function(e) { return e === record.Id }).length > 0) This works fine
– aniltc
Jan 3 at 13:05
1
@aniltc Sorry, had a minor typo: should befunction
notfuntion
. Fixed it now.
– Terry
Jan 3 at 13:08
add a comment |
1
This should be the accepted answer due to compatibility.
– BRO_THOM
Jan 3 at 12:56
It showing an error in step1
– aniltc
Jan 3 at 12:58
if (MyObject.eId.filter(function(e) { return e === record.Id }).length > 0) This works fine
– aniltc
Jan 3 at 13:05
1
@aniltc Sorry, had a minor typo: should befunction
notfuntion
. Fixed it now.
– Terry
Jan 3 at 13:08
1
1
This should be the accepted answer due to compatibility.
– BRO_THOM
Jan 3 at 12:56
This should be the accepted answer due to compatibility.
– BRO_THOM
Jan 3 at 12:56
It showing an error in step1
– aniltc
Jan 3 at 12:58
It showing an error in step1
– aniltc
Jan 3 at 12:58
if (MyObject.eId.filter(function(e) { return e === record.Id }).length > 0) This works fine
– aniltc
Jan 3 at 13:05
if (MyObject.eId.filter(function(e) { return e === record.Id }).length > 0) This works fine
– aniltc
Jan 3 at 13:05
1
1
@aniltc Sorry, had a minor typo: should be
function
not funtion
. Fixed it now.– Terry
Jan 3 at 13:08
@aniltc Sorry, had a minor typo: should be
function
not funtion
. Fixed it now.– Terry
Jan 3 at 13:08
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54022483%2ffacing-issues-in-js-filter-function-in-ie-11%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Maybe you want to use a polyfill? Take a look at this.
– JO3-W3B-D3V
Jan 3 at 12:41
1
For non arrow function your code should look like:
if ( MyObject.eId.filter(function(e) { return e === record.Id; }).length > 0 ) {
– HMR
Jan 3 at 12:47