Check pathname for Array
i got a question:
This code snippet works great:
$(document).ready(function(){
var pathname = window.location.pathname;
if(pathname.indexOf( 'word1' ) > -1){
// do something
}
});
But if i want to check for array of word´s it doesnt work:
$(document).ready(function(){
var myArray1 = new Array( "word1","word2","word3","word4" );
var pathname = window.location.pathname;
if(pathname.indexOf( myArray1 ) > -1){
// never executed! why?
}
});
Anybody could help with this problem? Greetings!
javascript jquery
add a comment |
i got a question:
This code snippet works great:
$(document).ready(function(){
var pathname = window.location.pathname;
if(pathname.indexOf( 'word1' ) > -1){
// do something
}
});
But if i want to check for array of word´s it doesnt work:
$(document).ready(function(){
var myArray1 = new Array( "word1","word2","word3","word4" );
var pathname = window.location.pathname;
if(pathname.indexOf( myArray1 ) > -1){
// never executed! why?
}
});
Anybody could help with this problem? Greetings!
javascript jquery
1
if (myArray1.indexOf(pathname) != -1) { ... }
.
– Ja͢ck
Mar 2 '14 at 23:13
add a comment |
i got a question:
This code snippet works great:
$(document).ready(function(){
var pathname = window.location.pathname;
if(pathname.indexOf( 'word1' ) > -1){
// do something
}
});
But if i want to check for array of word´s it doesnt work:
$(document).ready(function(){
var myArray1 = new Array( "word1","word2","word3","word4" );
var pathname = window.location.pathname;
if(pathname.indexOf( myArray1 ) > -1){
// never executed! why?
}
});
Anybody could help with this problem? Greetings!
javascript jquery
i got a question:
This code snippet works great:
$(document).ready(function(){
var pathname = window.location.pathname;
if(pathname.indexOf( 'word1' ) > -1){
// do something
}
});
But if i want to check for array of word´s it doesnt work:
$(document).ready(function(){
var myArray1 = new Array( "word1","word2","word3","word4" );
var pathname = window.location.pathname;
if(pathname.indexOf( myArray1 ) > -1){
// never executed! why?
}
});
Anybody could help with this problem? Greetings!
javascript jquery
javascript jquery
edited Mar 2 '14 at 23:08
Felix Kling
554k128862919
554k128862919
asked Mar 2 '14 at 23:03
user3297073user3297073
598
598
1
if (myArray1.indexOf(pathname) != -1) { ... }
.
– Ja͢ck
Mar 2 '14 at 23:13
add a comment |
1
if (myArray1.indexOf(pathname) != -1) { ... }
.
– Ja͢ck
Mar 2 '14 at 23:13
1
1
if (myArray1.indexOf(pathname) != -1) { ... }
.– Ja͢ck
Mar 2 '14 at 23:13
if (myArray1.indexOf(pathname) != -1) { ... }
.– Ja͢ck
Mar 2 '14 at 23:13
add a comment |
6 Answers
6
active
oldest
votes
jQuery has a built in method for that, $.inArray
:
$(document).ready(function(){
var pathname = window.location.pathname;
if ( $.inArray(pathname, ["word1","word2","word3","word4"] ) != -1 ) {
// do stuff
}
});
then there's regex
$(document).ready(function(){
if ( /(word1|word2|word3|word4)/.test(window.location.pathname) ) {
// do stuff
}
});
If you wanna get fancy you can do the !!~ pattern for any indexOf type functions: if(!!~$.inArray(pathname, [...])) {
– TypingTurtle
Mar 2 '14 at 23:13
But$.inArray("word1 word2", ["word1","word2","word3","word4"])
won't match, is that what OP wants?
– ocanal
Mar 2 '14 at 23:22
add a comment |
If you want to test pathname
against an array of values, I suggest looping. You cannot send in an array object as an argument to the indexOf()
method. You can only send strings.
$(document).ready(function(){
var myArray1 = new Array( "word1","word2","word3","word4" );
var pathname = window.location.pathname;
for(stringy in myArray1){
if(pathname.indexOf( stringy ) > -1){
console.log('Match Found');
}
}
});
Look here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf
Use a normalfor
loop to iterate over arrays (notfor...in
).stringy
doesn't even refer to the element in the array, but the index.
– Felix Kling
Mar 2 '14 at 23:09
add a comment |
You could use jQuery.grep()
for this:
if ($.grep(myArray1, function(word) {
return pathname.indexOf(word) != -1;
})) {
// do something
}
Or, use native functions:
if (myArray1.some(function(word) {
return pathname.indexOf(word) != -1;
})) {
// do something
}
add a comment |
indexOf
looks for occurrences of a given string in another string. So you can't invoke it with an array as parameter. You must invoke it several times, each one with a string as parameter.
$(document).ready(function(){
var myArray1 = new Array( "word1","word2","word3","word4" );
var pathname = window.location.pathname;
for(var i=0; i<myArray1.length; i++) {
if(pathname.indexOf( myArray1[i] ) > -1){
// will be executed
}
}
});
add a comment |
string.indexOf
doesn't take array as a parameter, you should handle it yourself,
Ok I will make it a little bit different, you can also do this with Regex,
$(document).ready(function(){
var myArray1 = new Array( "word1","word2","word3","word4" );
var pathname = window.location.pathname;
if (pathname.match(new RegExp(myArray1.join("|")))) {
// yes, there is at least one match.
}
});
I don't know whether if you want it to match all words in the array.
Use a normalfor
loop to iterate over arrays (notfor...in
).
– Felix Kling
Mar 2 '14 at 23:09
@FelixKling Is afor(string in array)
fine?
– turnt
Mar 2 '14 at 23:09
@Cygwinnian: In general, no: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/….
– Felix Kling
Mar 2 '14 at 23:10
add a comment |
I made a way to test n
quantities of pathnames.
import pathToRegexp from 'path-to-regexp';
const ALLOWED_PATHS = [
'test',
'test/:param'
]
const allowed = ALLOWED_PATHS.map((path) => {
const regex = pathToRegexp(path)
return regex.test(window.location.pathname);
});
if(allowed.some(Boolean)) {
// Match
} else {
// Not Match
}
...
Hope this helps you!
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%2f22134886%2fcheck-pathname-for-array%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
jQuery has a built in method for that, $.inArray
:
$(document).ready(function(){
var pathname = window.location.pathname;
if ( $.inArray(pathname, ["word1","word2","word3","word4"] ) != -1 ) {
// do stuff
}
});
then there's regex
$(document).ready(function(){
if ( /(word1|word2|word3|word4)/.test(window.location.pathname) ) {
// do stuff
}
});
If you wanna get fancy you can do the !!~ pattern for any indexOf type functions: if(!!~$.inArray(pathname, [...])) {
– TypingTurtle
Mar 2 '14 at 23:13
But$.inArray("word1 word2", ["word1","word2","word3","word4"])
won't match, is that what OP wants?
– ocanal
Mar 2 '14 at 23:22
add a comment |
jQuery has a built in method for that, $.inArray
:
$(document).ready(function(){
var pathname = window.location.pathname;
if ( $.inArray(pathname, ["word1","word2","word3","word4"] ) != -1 ) {
// do stuff
}
});
then there's regex
$(document).ready(function(){
if ( /(word1|word2|word3|word4)/.test(window.location.pathname) ) {
// do stuff
}
});
If you wanna get fancy you can do the !!~ pattern for any indexOf type functions: if(!!~$.inArray(pathname, [...])) {
– TypingTurtle
Mar 2 '14 at 23:13
But$.inArray("word1 word2", ["word1","word2","word3","word4"])
won't match, is that what OP wants?
– ocanal
Mar 2 '14 at 23:22
add a comment |
jQuery has a built in method for that, $.inArray
:
$(document).ready(function(){
var pathname = window.location.pathname;
if ( $.inArray(pathname, ["word1","word2","word3","word4"] ) != -1 ) {
// do stuff
}
});
then there's regex
$(document).ready(function(){
if ( /(word1|word2|word3|word4)/.test(window.location.pathname) ) {
// do stuff
}
});
jQuery has a built in method for that, $.inArray
:
$(document).ready(function(){
var pathname = window.location.pathname;
if ( $.inArray(pathname, ["word1","word2","word3","word4"] ) != -1 ) {
// do stuff
}
});
then there's regex
$(document).ready(function(){
if ( /(word1|word2|word3|word4)/.test(window.location.pathname) ) {
// do stuff
}
});
edited Mar 2 '14 at 23:16
answered Mar 2 '14 at 23:11
adeneoadeneo
263k19282312
263k19282312
If you wanna get fancy you can do the !!~ pattern for any indexOf type functions: if(!!~$.inArray(pathname, [...])) {
– TypingTurtle
Mar 2 '14 at 23:13
But$.inArray("word1 word2", ["word1","word2","word3","word4"])
won't match, is that what OP wants?
– ocanal
Mar 2 '14 at 23:22
add a comment |
If you wanna get fancy you can do the !!~ pattern for any indexOf type functions: if(!!~$.inArray(pathname, [...])) {
– TypingTurtle
Mar 2 '14 at 23:13
But$.inArray("word1 word2", ["word1","word2","word3","word4"])
won't match, is that what OP wants?
– ocanal
Mar 2 '14 at 23:22
If you wanna get fancy you can do the !!~ pattern for any indexOf type functions: if(!!~$.inArray(pathname, [...])) {
– TypingTurtle
Mar 2 '14 at 23:13
If you wanna get fancy you can do the !!~ pattern for any indexOf type functions: if(!!~$.inArray(pathname, [...])) {
– TypingTurtle
Mar 2 '14 at 23:13
But
$.inArray("word1 word2", ["word1","word2","word3","word4"])
won't match, is that what OP wants?– ocanal
Mar 2 '14 at 23:22
But
$.inArray("word1 word2", ["word1","word2","word3","word4"])
won't match, is that what OP wants?– ocanal
Mar 2 '14 at 23:22
add a comment |
If you want to test pathname
against an array of values, I suggest looping. You cannot send in an array object as an argument to the indexOf()
method. You can only send strings.
$(document).ready(function(){
var myArray1 = new Array( "word1","word2","word3","word4" );
var pathname = window.location.pathname;
for(stringy in myArray1){
if(pathname.indexOf( stringy ) > -1){
console.log('Match Found');
}
}
});
Look here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf
Use a normalfor
loop to iterate over arrays (notfor...in
).stringy
doesn't even refer to the element in the array, but the index.
– Felix Kling
Mar 2 '14 at 23:09
add a comment |
If you want to test pathname
against an array of values, I suggest looping. You cannot send in an array object as an argument to the indexOf()
method. You can only send strings.
$(document).ready(function(){
var myArray1 = new Array( "word1","word2","word3","word4" );
var pathname = window.location.pathname;
for(stringy in myArray1){
if(pathname.indexOf( stringy ) > -1){
console.log('Match Found');
}
}
});
Look here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf
Use a normalfor
loop to iterate over arrays (notfor...in
).stringy
doesn't even refer to the element in the array, but the index.
– Felix Kling
Mar 2 '14 at 23:09
add a comment |
If you want to test pathname
against an array of values, I suggest looping. You cannot send in an array object as an argument to the indexOf()
method. You can only send strings.
$(document).ready(function(){
var myArray1 = new Array( "word1","word2","word3","word4" );
var pathname = window.location.pathname;
for(stringy in myArray1){
if(pathname.indexOf( stringy ) > -1){
console.log('Match Found');
}
}
});
Look here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf
If you want to test pathname
against an array of values, I suggest looping. You cannot send in an array object as an argument to the indexOf()
method. You can only send strings.
$(document).ready(function(){
var myArray1 = new Array( "word1","word2","word3","word4" );
var pathname = window.location.pathname;
for(stringy in myArray1){
if(pathname.indexOf( stringy ) > -1){
console.log('Match Found');
}
}
});
Look here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf
answered Mar 2 '14 at 23:07
turntturnt
2,30351735
2,30351735
Use a normalfor
loop to iterate over arrays (notfor...in
).stringy
doesn't even refer to the element in the array, but the index.
– Felix Kling
Mar 2 '14 at 23:09
add a comment |
Use a normalfor
loop to iterate over arrays (notfor...in
).stringy
doesn't even refer to the element in the array, but the index.
– Felix Kling
Mar 2 '14 at 23:09
Use a normal
for
loop to iterate over arrays (not for...in
). stringy
doesn't even refer to the element in the array, but the index.– Felix Kling
Mar 2 '14 at 23:09
Use a normal
for
loop to iterate over arrays (not for...in
). stringy
doesn't even refer to the element in the array, but the index.– Felix Kling
Mar 2 '14 at 23:09
add a comment |
You could use jQuery.grep()
for this:
if ($.grep(myArray1, function(word) {
return pathname.indexOf(word) != -1;
})) {
// do something
}
Or, use native functions:
if (myArray1.some(function(word) {
return pathname.indexOf(word) != -1;
})) {
// do something
}
add a comment |
You could use jQuery.grep()
for this:
if ($.grep(myArray1, function(word) {
return pathname.indexOf(word) != -1;
})) {
// do something
}
Or, use native functions:
if (myArray1.some(function(word) {
return pathname.indexOf(word) != -1;
})) {
// do something
}
add a comment |
You could use jQuery.grep()
for this:
if ($.grep(myArray1, function(word) {
return pathname.indexOf(word) != -1;
})) {
// do something
}
Or, use native functions:
if (myArray1.some(function(word) {
return pathname.indexOf(word) != -1;
})) {
// do something
}
You could use jQuery.grep()
for this:
if ($.grep(myArray1, function(word) {
return pathname.indexOf(word) != -1;
})) {
// do something
}
Or, use native functions:
if (myArray1.some(function(word) {
return pathname.indexOf(word) != -1;
})) {
// do something
}
answered Mar 2 '14 at 23:22
Ja͢ckJa͢ck
145k27210267
145k27210267
add a comment |
add a comment |
indexOf
looks for occurrences of a given string in another string. So you can't invoke it with an array as parameter. You must invoke it several times, each one with a string as parameter.
$(document).ready(function(){
var myArray1 = new Array( "word1","word2","word3","word4" );
var pathname = window.location.pathname;
for(var i=0; i<myArray1.length; i++) {
if(pathname.indexOf( myArray1[i] ) > -1){
// will be executed
}
}
});
add a comment |
indexOf
looks for occurrences of a given string in another string. So you can't invoke it with an array as parameter. You must invoke it several times, each one with a string as parameter.
$(document).ready(function(){
var myArray1 = new Array( "word1","word2","word3","word4" );
var pathname = window.location.pathname;
for(var i=0; i<myArray1.length; i++) {
if(pathname.indexOf( myArray1[i] ) > -1){
// will be executed
}
}
});
add a comment |
indexOf
looks for occurrences of a given string in another string. So you can't invoke it with an array as parameter. You must invoke it several times, each one with a string as parameter.
$(document).ready(function(){
var myArray1 = new Array( "word1","word2","word3","word4" );
var pathname = window.location.pathname;
for(var i=0; i<myArray1.length; i++) {
if(pathname.indexOf( myArray1[i] ) > -1){
// will be executed
}
}
});
indexOf
looks for occurrences of a given string in another string. So you can't invoke it with an array as parameter. You must invoke it several times, each one with a string as parameter.
$(document).ready(function(){
var myArray1 = new Array( "word1","word2","word3","word4" );
var pathname = window.location.pathname;
for(var i=0; i<myArray1.length; i++) {
if(pathname.indexOf( myArray1[i] ) > -1){
// will be executed
}
}
});
edited Mar 2 '15 at 20:06
GitaarLAB
11.7k74470
11.7k74470
answered Mar 2 '14 at 23:11
Pascal Le MerrerPascal Le Merrer
4,4441328
4,4441328
add a comment |
add a comment |
string.indexOf
doesn't take array as a parameter, you should handle it yourself,
Ok I will make it a little bit different, you can also do this with Regex,
$(document).ready(function(){
var myArray1 = new Array( "word1","word2","word3","word4" );
var pathname = window.location.pathname;
if (pathname.match(new RegExp(myArray1.join("|")))) {
// yes, there is at least one match.
}
});
I don't know whether if you want it to match all words in the array.
Use a normalfor
loop to iterate over arrays (notfor...in
).
– Felix Kling
Mar 2 '14 at 23:09
@FelixKling Is afor(string in array)
fine?
– turnt
Mar 2 '14 at 23:09
@Cygwinnian: In general, no: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/….
– Felix Kling
Mar 2 '14 at 23:10
add a comment |
string.indexOf
doesn't take array as a parameter, you should handle it yourself,
Ok I will make it a little bit different, you can also do this with Regex,
$(document).ready(function(){
var myArray1 = new Array( "word1","word2","word3","word4" );
var pathname = window.location.pathname;
if (pathname.match(new RegExp(myArray1.join("|")))) {
// yes, there is at least one match.
}
});
I don't know whether if you want it to match all words in the array.
Use a normalfor
loop to iterate over arrays (notfor...in
).
– Felix Kling
Mar 2 '14 at 23:09
@FelixKling Is afor(string in array)
fine?
– turnt
Mar 2 '14 at 23:09
@Cygwinnian: In general, no: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/….
– Felix Kling
Mar 2 '14 at 23:10
add a comment |
string.indexOf
doesn't take array as a parameter, you should handle it yourself,
Ok I will make it a little bit different, you can also do this with Regex,
$(document).ready(function(){
var myArray1 = new Array( "word1","word2","word3","word4" );
var pathname = window.location.pathname;
if (pathname.match(new RegExp(myArray1.join("|")))) {
// yes, there is at least one match.
}
});
I don't know whether if you want it to match all words in the array.
string.indexOf
doesn't take array as a parameter, you should handle it yourself,
Ok I will make it a little bit different, you can also do this with Regex,
$(document).ready(function(){
var myArray1 = new Array( "word1","word2","word3","word4" );
var pathname = window.location.pathname;
if (pathname.match(new RegExp(myArray1.join("|")))) {
// yes, there is at least one match.
}
});
I don't know whether if you want it to match all words in the array.
edited May 10 '18 at 16:37
Ivan
5,33331341
5,33331341
answered Mar 2 '14 at 23:08
ocanalocanal
9,2191556109
9,2191556109
Use a normalfor
loop to iterate over arrays (notfor...in
).
– Felix Kling
Mar 2 '14 at 23:09
@FelixKling Is afor(string in array)
fine?
– turnt
Mar 2 '14 at 23:09
@Cygwinnian: In general, no: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/….
– Felix Kling
Mar 2 '14 at 23:10
add a comment |
Use a normalfor
loop to iterate over arrays (notfor...in
).
– Felix Kling
Mar 2 '14 at 23:09
@FelixKling Is afor(string in array)
fine?
– turnt
Mar 2 '14 at 23:09
@Cygwinnian: In general, no: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/….
– Felix Kling
Mar 2 '14 at 23:10
Use a normal
for
loop to iterate over arrays (not for...in
).– Felix Kling
Mar 2 '14 at 23:09
Use a normal
for
loop to iterate over arrays (not for...in
).– Felix Kling
Mar 2 '14 at 23:09
@FelixKling Is a
for(string in array)
fine?– turnt
Mar 2 '14 at 23:09
@FelixKling Is a
for(string in array)
fine?– turnt
Mar 2 '14 at 23:09
@Cygwinnian: In general, no: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/….
– Felix Kling
Mar 2 '14 at 23:10
@Cygwinnian: In general, no: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/….
– Felix Kling
Mar 2 '14 at 23:10
add a comment |
I made a way to test n
quantities of pathnames.
import pathToRegexp from 'path-to-regexp';
const ALLOWED_PATHS = [
'test',
'test/:param'
]
const allowed = ALLOWED_PATHS.map((path) => {
const regex = pathToRegexp(path)
return regex.test(window.location.pathname);
});
if(allowed.some(Boolean)) {
// Match
} else {
// Not Match
}
...
Hope this helps you!
add a comment |
I made a way to test n
quantities of pathnames.
import pathToRegexp from 'path-to-regexp';
const ALLOWED_PATHS = [
'test',
'test/:param'
]
const allowed = ALLOWED_PATHS.map((path) => {
const regex = pathToRegexp(path)
return regex.test(window.location.pathname);
});
if(allowed.some(Boolean)) {
// Match
} else {
// Not Match
}
...
Hope this helps you!
add a comment |
I made a way to test n
quantities of pathnames.
import pathToRegexp from 'path-to-regexp';
const ALLOWED_PATHS = [
'test',
'test/:param'
]
const allowed = ALLOWED_PATHS.map((path) => {
const regex = pathToRegexp(path)
return regex.test(window.location.pathname);
});
if(allowed.some(Boolean)) {
// Match
} else {
// Not Match
}
...
Hope this helps you!
I made a way to test n
quantities of pathnames.
import pathToRegexp from 'path-to-regexp';
const ALLOWED_PATHS = [
'test',
'test/:param'
]
const allowed = ALLOWED_PATHS.map((path) => {
const regex = pathToRegexp(path)
return regex.test(window.location.pathname);
});
if(allowed.some(Boolean)) {
// Match
} else {
// Not Match
}
...
Hope this helps you!
edited Nov 20 '18 at 5:36
answered Nov 7 '18 at 4:21
slorenzoslorenzo
1,9192038
1,9192038
add a comment |
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%2f22134886%2fcheck-pathname-for-array%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
1
if (myArray1.indexOf(pathname) != -1) { ... }
.– Ja͢ck
Mar 2 '14 at 23:13