Test for array of string type in TypeScript
How can I test if a variable is an array of string in TypeScript? Something like this:
function f(): string {
var a: string = ["A", "B", "C"];
if (typeof a === "string") {
return "Yes"
}
else {
// returns no as it's 'object'
return "No"
}
};
TypeScript.io here: http://typescript.io/k0ZiJzso0Qg/2
Edit: I've updated the text to ask for a test for string. This was only in the code example previously.
typescript
add a comment |
How can I test if a variable is an array of string in TypeScript? Something like this:
function f(): string {
var a: string = ["A", "B", "C"];
if (typeof a === "string") {
return "Yes"
}
else {
// returns no as it's 'object'
return "No"
}
};
TypeScript.io here: http://typescript.io/k0ZiJzso0Qg/2
Edit: I've updated the text to ask for a test for string. This was only in the code example previously.
typescript
possible duplicate of How do you check if a variable is an array in JavaScript?
– WiredPrairie
Apr 17 '14 at 10:48
As TypeScript just compiles to JavaScript, the answers may be found by searching for a JavaScript solution. Further, it's worth it to see some of the answers as the answer depends on the host and how it's being used and passed.
– WiredPrairie
Apr 17 '14 at 10:50
add a comment |
How can I test if a variable is an array of string in TypeScript? Something like this:
function f(): string {
var a: string = ["A", "B", "C"];
if (typeof a === "string") {
return "Yes"
}
else {
// returns no as it's 'object'
return "No"
}
};
TypeScript.io here: http://typescript.io/k0ZiJzso0Qg/2
Edit: I've updated the text to ask for a test for string. This was only in the code example previously.
typescript
How can I test if a variable is an array of string in TypeScript? Something like this:
function f(): string {
var a: string = ["A", "B", "C"];
if (typeof a === "string") {
return "Yes"
}
else {
// returns no as it's 'object'
return "No"
}
};
TypeScript.io here: http://typescript.io/k0ZiJzso0Qg/2
Edit: I've updated the text to ask for a test for string. This was only in the code example previously.
typescript
typescript
edited Apr 17 '14 at 11:22
Sean Kearon
asked Apr 17 '14 at 10:11
Sean KearonSean Kearon
5,01595983
5,01595983
possible duplicate of How do you check if a variable is an array in JavaScript?
– WiredPrairie
Apr 17 '14 at 10:48
As TypeScript just compiles to JavaScript, the answers may be found by searching for a JavaScript solution. Further, it's worth it to see some of the answers as the answer depends on the host and how it's being used and passed.
– WiredPrairie
Apr 17 '14 at 10:50
add a comment |
possible duplicate of How do you check if a variable is an array in JavaScript?
– WiredPrairie
Apr 17 '14 at 10:48
As TypeScript just compiles to JavaScript, the answers may be found by searching for a JavaScript solution. Further, it's worth it to see some of the answers as the answer depends on the host and how it's being used and passed.
– WiredPrairie
Apr 17 '14 at 10:50
possible duplicate of How do you check if a variable is an array in JavaScript?
– WiredPrairie
Apr 17 '14 at 10:48
possible duplicate of How do you check if a variable is an array in JavaScript?
– WiredPrairie
Apr 17 '14 at 10:48
As TypeScript just compiles to JavaScript, the answers may be found by searching for a JavaScript solution. Further, it's worth it to see some of the answers as the answer depends on the host and how it's being used and passed.
– WiredPrairie
Apr 17 '14 at 10:50
As TypeScript just compiles to JavaScript, the answers may be found by searching for a JavaScript solution. Further, it's worth it to see some of the answers as the answer depends on the host and how it's being used and passed.
– WiredPrairie
Apr 17 '14 at 10:50
add a comment |
6 Answers
6
active
oldest
votes
You cannot test for string
in the general case but you can test for Array
quite easily the same as in JavaScript https://stackoverflow.com/a/767492/390330
If you specifically want for string
array you can do something like:
if (value instanceof Array) {
var somethingIsNotString = false;
value.forEach(function(item){
if(typeof item !== 'string'){
somethingIsNotString = true;
}
})
if(!somethingIsNotString && value.length > 0){
console.log('string!');
}
}
Thanks - that's what I needed!
– Sean Kearon
Apr 17 '14 at 13:42
add a comment |
Another option is Array.isArray()
if(! Array.isArray(classNames) ){
classNames = [classNames]
}
1
But this doesn't check for the elements being of typestring
.
– Ixx
Jan 8 at 11:13
1
Yeap. Then you need one additional checking.Array.isArray(classNames) && classNames.every(it => typeof it === 'string')
– grigson
Jan 9 at 15:21
@grigson how about performance when checking 400+ results? Should I disconsider this kind of type check, check just the first child or is it safe tu use this "every" thing?
– giovannipds
Jan 17 at 11:35
add a comment |
Here is the most concise solution so far:
function isArrayOfString(value: any): boolean {
return Array.isArray(value) && value.every(item => typeof item === "string")
}
Note that value.every
will return true
for an empty array. If you need to return false
for an empty array, you should add !!value.length
to the condition clause:
function isNonEmptyArrayOfStrings(value: any): boolean {
return Array.isArray(value) && !!value.length && value.every(item => typeof item === "string");
}
There is no way to check the type of an empty array since there is no type information at runtime.
add a comment |
I know this has been answered, but TypeScript introduced type guards: https://www.typescriptlang.org/docs/handbook/advanced-types.html#typeof-type-guards
If you have a type like: Object | string
and what to do something conditionally based on what type it is - you can use this type guarding:
function isStringArray(value: any): value is string {
if (value instanceof Array) {
value.forEach(function(item) { // maybe only check first value?
if (typeof item !== 'string') {
return false
}
})
return true
}
return false
}
function join<T>(value: string | T) {
if (isStringArray(value)) {
return value.join(',') // value is string here
} else {
return value.map((x) => x.toString()).join(',') // value is T here
}
}
There is an issue with an empty array being typed as string
, but that might be okay
6
Thereturn false
in theforEach
has no effect.
– Ishtar
May 9 '18 at 8:39
add a comment |
Try this:
if (value instanceof Array) {
alert('value is Array!');
} else {
alert('Not an array');
}
5
Rather than copying another answer, please just point out the duplicate as a comment, especially as this doesn't work in all cases.
– WiredPrairie
Apr 17 '14 at 10:49
This just check the main type not every Array's child.
– giovannipds
Jan 17 at 11:39
add a comment |
there is a little problem here because the
if (typeof item !== 'string') {
return false
}
will not stop the foreach.
So the function will return true even if the array does contain none string values.
This seems to wok for me:
function isStringArray(value: any): value is number {
if (Object.prototype.toString.call(value) === '[object Array]') {
if (value.length < 1) {
return false;
} else {
return value.every((d: any) => typeof d === 'string');
}
}
return false;
}
Greetings, Hans
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%2f23130292%2ftest-for-array-of-string-type-in-typescript%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
You cannot test for string
in the general case but you can test for Array
quite easily the same as in JavaScript https://stackoverflow.com/a/767492/390330
If you specifically want for string
array you can do something like:
if (value instanceof Array) {
var somethingIsNotString = false;
value.forEach(function(item){
if(typeof item !== 'string'){
somethingIsNotString = true;
}
})
if(!somethingIsNotString && value.length > 0){
console.log('string!');
}
}
Thanks - that's what I needed!
– Sean Kearon
Apr 17 '14 at 13:42
add a comment |
You cannot test for string
in the general case but you can test for Array
quite easily the same as in JavaScript https://stackoverflow.com/a/767492/390330
If you specifically want for string
array you can do something like:
if (value instanceof Array) {
var somethingIsNotString = false;
value.forEach(function(item){
if(typeof item !== 'string'){
somethingIsNotString = true;
}
})
if(!somethingIsNotString && value.length > 0){
console.log('string!');
}
}
Thanks - that's what I needed!
– Sean Kearon
Apr 17 '14 at 13:42
add a comment |
You cannot test for string
in the general case but you can test for Array
quite easily the same as in JavaScript https://stackoverflow.com/a/767492/390330
If you specifically want for string
array you can do something like:
if (value instanceof Array) {
var somethingIsNotString = false;
value.forEach(function(item){
if(typeof item !== 'string'){
somethingIsNotString = true;
}
})
if(!somethingIsNotString && value.length > 0){
console.log('string!');
}
}
You cannot test for string
in the general case but you can test for Array
quite easily the same as in JavaScript https://stackoverflow.com/a/767492/390330
If you specifically want for string
array you can do something like:
if (value instanceof Array) {
var somethingIsNotString = false;
value.forEach(function(item){
if(typeof item !== 'string'){
somethingIsNotString = true;
}
})
if(!somethingIsNotString && value.length > 0){
console.log('string!');
}
}
edited Feb 15 at 11:14
Nedim Kurbegović
5210
5210
answered Apr 17 '14 at 12:53
basaratbasarat
140k26260369
140k26260369
Thanks - that's what I needed!
– Sean Kearon
Apr 17 '14 at 13:42
add a comment |
Thanks - that's what I needed!
– Sean Kearon
Apr 17 '14 at 13:42
Thanks - that's what I needed!
– Sean Kearon
Apr 17 '14 at 13:42
Thanks - that's what I needed!
– Sean Kearon
Apr 17 '14 at 13:42
add a comment |
Another option is Array.isArray()
if(! Array.isArray(classNames) ){
classNames = [classNames]
}
1
But this doesn't check for the elements being of typestring
.
– Ixx
Jan 8 at 11:13
1
Yeap. Then you need one additional checking.Array.isArray(classNames) && classNames.every(it => typeof it === 'string')
– grigson
Jan 9 at 15:21
@grigson how about performance when checking 400+ results? Should I disconsider this kind of type check, check just the first child or is it safe tu use this "every" thing?
– giovannipds
Jan 17 at 11:35
add a comment |
Another option is Array.isArray()
if(! Array.isArray(classNames) ){
classNames = [classNames]
}
1
But this doesn't check for the elements being of typestring
.
– Ixx
Jan 8 at 11:13
1
Yeap. Then you need one additional checking.Array.isArray(classNames) && classNames.every(it => typeof it === 'string')
– grigson
Jan 9 at 15:21
@grigson how about performance when checking 400+ results? Should I disconsider this kind of type check, check just the first child or is it safe tu use this "every" thing?
– giovannipds
Jan 17 at 11:35
add a comment |
Another option is Array.isArray()
if(! Array.isArray(classNames) ){
classNames = [classNames]
}
Another option is Array.isArray()
if(! Array.isArray(classNames) ){
classNames = [classNames]
}
edited Jan 13 '17 at 3:17
daremachine
1,40121528
1,40121528
answered Dec 26 '16 at 12:06
grigsongrigson
1,9561914
1,9561914
1
But this doesn't check for the elements being of typestring
.
– Ixx
Jan 8 at 11:13
1
Yeap. Then you need one additional checking.Array.isArray(classNames) && classNames.every(it => typeof it === 'string')
– grigson
Jan 9 at 15:21
@grigson how about performance when checking 400+ results? Should I disconsider this kind of type check, check just the first child or is it safe tu use this "every" thing?
– giovannipds
Jan 17 at 11:35
add a comment |
1
But this doesn't check for the elements being of typestring
.
– Ixx
Jan 8 at 11:13
1
Yeap. Then you need one additional checking.Array.isArray(classNames) && classNames.every(it => typeof it === 'string')
– grigson
Jan 9 at 15:21
@grigson how about performance when checking 400+ results? Should I disconsider this kind of type check, check just the first child or is it safe tu use this "every" thing?
– giovannipds
Jan 17 at 11:35
1
1
But this doesn't check for the elements being of type
string
.– Ixx
Jan 8 at 11:13
But this doesn't check for the elements being of type
string
.– Ixx
Jan 8 at 11:13
1
1
Yeap. Then you need one additional checking.
Array.isArray(classNames) && classNames.every(it => typeof it === 'string')
– grigson
Jan 9 at 15:21
Yeap. Then you need one additional checking.
Array.isArray(classNames) && classNames.every(it => typeof it === 'string')
– grigson
Jan 9 at 15:21
@grigson how about performance when checking 400+ results? Should I disconsider this kind of type check, check just the first child or is it safe tu use this "every" thing?
– giovannipds
Jan 17 at 11:35
@grigson how about performance when checking 400+ results? Should I disconsider this kind of type check, check just the first child or is it safe tu use this "every" thing?
– giovannipds
Jan 17 at 11:35
add a comment |
Here is the most concise solution so far:
function isArrayOfString(value: any): boolean {
return Array.isArray(value) && value.every(item => typeof item === "string")
}
Note that value.every
will return true
for an empty array. If you need to return false
for an empty array, you should add !!value.length
to the condition clause:
function isNonEmptyArrayOfStrings(value: any): boolean {
return Array.isArray(value) && !!value.length && value.every(item => typeof item === "string");
}
There is no way to check the type of an empty array since there is no type information at runtime.
add a comment |
Here is the most concise solution so far:
function isArrayOfString(value: any): boolean {
return Array.isArray(value) && value.every(item => typeof item === "string")
}
Note that value.every
will return true
for an empty array. If you need to return false
for an empty array, you should add !!value.length
to the condition clause:
function isNonEmptyArrayOfStrings(value: any): boolean {
return Array.isArray(value) && !!value.length && value.every(item => typeof item === "string");
}
There is no way to check the type of an empty array since there is no type information at runtime.
add a comment |
Here is the most concise solution so far:
function isArrayOfString(value: any): boolean {
return Array.isArray(value) && value.every(item => typeof item === "string")
}
Note that value.every
will return true
for an empty array. If you need to return false
for an empty array, you should add !!value.length
to the condition clause:
function isNonEmptyArrayOfStrings(value: any): boolean {
return Array.isArray(value) && !!value.length && value.every(item => typeof item === "string");
}
There is no way to check the type of an empty array since there is no type information at runtime.
Here is the most concise solution so far:
function isArrayOfString(value: any): boolean {
return Array.isArray(value) && value.every(item => typeof item === "string")
}
Note that value.every
will return true
for an empty array. If you need to return false
for an empty array, you should add !!value.length
to the condition clause:
function isNonEmptyArrayOfStrings(value: any): boolean {
return Array.isArray(value) && !!value.length && value.every(item => typeof item === "string");
}
There is no way to check the type of an empty array since there is no type information at runtime.
edited Feb 2 at 8:49
answered May 25 '18 at 7:08
asmironovasmironov
520616
520616
add a comment |
add a comment |
I know this has been answered, but TypeScript introduced type guards: https://www.typescriptlang.org/docs/handbook/advanced-types.html#typeof-type-guards
If you have a type like: Object | string
and what to do something conditionally based on what type it is - you can use this type guarding:
function isStringArray(value: any): value is string {
if (value instanceof Array) {
value.forEach(function(item) { // maybe only check first value?
if (typeof item !== 'string') {
return false
}
})
return true
}
return false
}
function join<T>(value: string | T) {
if (isStringArray(value)) {
return value.join(',') // value is string here
} else {
return value.map((x) => x.toString()).join(',') // value is T here
}
}
There is an issue with an empty array being typed as string
, but that might be okay
6
Thereturn false
in theforEach
has no effect.
– Ishtar
May 9 '18 at 8:39
add a comment |
I know this has been answered, but TypeScript introduced type guards: https://www.typescriptlang.org/docs/handbook/advanced-types.html#typeof-type-guards
If you have a type like: Object | string
and what to do something conditionally based on what type it is - you can use this type guarding:
function isStringArray(value: any): value is string {
if (value instanceof Array) {
value.forEach(function(item) { // maybe only check first value?
if (typeof item !== 'string') {
return false
}
})
return true
}
return false
}
function join<T>(value: string | T) {
if (isStringArray(value)) {
return value.join(',') // value is string here
} else {
return value.map((x) => x.toString()).join(',') // value is T here
}
}
There is an issue with an empty array being typed as string
, but that might be okay
6
Thereturn false
in theforEach
has no effect.
– Ishtar
May 9 '18 at 8:39
add a comment |
I know this has been answered, but TypeScript introduced type guards: https://www.typescriptlang.org/docs/handbook/advanced-types.html#typeof-type-guards
If you have a type like: Object | string
and what to do something conditionally based on what type it is - you can use this type guarding:
function isStringArray(value: any): value is string {
if (value instanceof Array) {
value.forEach(function(item) { // maybe only check first value?
if (typeof item !== 'string') {
return false
}
})
return true
}
return false
}
function join<T>(value: string | T) {
if (isStringArray(value)) {
return value.join(',') // value is string here
} else {
return value.map((x) => x.toString()).join(',') // value is T here
}
}
There is an issue with an empty array being typed as string
, but that might be okay
I know this has been answered, but TypeScript introduced type guards: https://www.typescriptlang.org/docs/handbook/advanced-types.html#typeof-type-guards
If you have a type like: Object | string
and what to do something conditionally based on what type it is - you can use this type guarding:
function isStringArray(value: any): value is string {
if (value instanceof Array) {
value.forEach(function(item) { // maybe only check first value?
if (typeof item !== 'string') {
return false
}
})
return true
}
return false
}
function join<T>(value: string | T) {
if (isStringArray(value)) {
return value.join(',') // value is string here
} else {
return value.map((x) => x.toString()).join(',') // value is T here
}
}
There is an issue with an empty array being typed as string
, but that might be okay
answered Jun 7 '17 at 20:46
Nicholas BollNicholas Boll
42525
42525
6
Thereturn false
in theforEach
has no effect.
– Ishtar
May 9 '18 at 8:39
add a comment |
6
Thereturn false
in theforEach
has no effect.
– Ishtar
May 9 '18 at 8:39
6
6
The
return false
in the forEach
has no effect.– Ishtar
May 9 '18 at 8:39
The
return false
in the forEach
has no effect.– Ishtar
May 9 '18 at 8:39
add a comment |
Try this:
if (value instanceof Array) {
alert('value is Array!');
} else {
alert('Not an array');
}
5
Rather than copying another answer, please just point out the duplicate as a comment, especially as this doesn't work in all cases.
– WiredPrairie
Apr 17 '14 at 10:49
This just check the main type not every Array's child.
– giovannipds
Jan 17 at 11:39
add a comment |
Try this:
if (value instanceof Array) {
alert('value is Array!');
} else {
alert('Not an array');
}
5
Rather than copying another answer, please just point out the duplicate as a comment, especially as this doesn't work in all cases.
– WiredPrairie
Apr 17 '14 at 10:49
This just check the main type not every Array's child.
– giovannipds
Jan 17 at 11:39
add a comment |
Try this:
if (value instanceof Array) {
alert('value is Array!');
} else {
alert('Not an array');
}
Try this:
if (value instanceof Array) {
alert('value is Array!');
} else {
alert('Not an array');
}
answered Apr 17 '14 at 10:41
TcanarchyTcanarchy
454417
454417
5
Rather than copying another answer, please just point out the duplicate as a comment, especially as this doesn't work in all cases.
– WiredPrairie
Apr 17 '14 at 10:49
This just check the main type not every Array's child.
– giovannipds
Jan 17 at 11:39
add a comment |
5
Rather than copying another answer, please just point out the duplicate as a comment, especially as this doesn't work in all cases.
– WiredPrairie
Apr 17 '14 at 10:49
This just check the main type not every Array's child.
– giovannipds
Jan 17 at 11:39
5
5
Rather than copying another answer, please just point out the duplicate as a comment, especially as this doesn't work in all cases.
– WiredPrairie
Apr 17 '14 at 10:49
Rather than copying another answer, please just point out the duplicate as a comment, especially as this doesn't work in all cases.
– WiredPrairie
Apr 17 '14 at 10:49
This just check the main type not every Array's child.
– giovannipds
Jan 17 at 11:39
This just check the main type not every Array's child.
– giovannipds
Jan 17 at 11:39
add a comment |
there is a little problem here because the
if (typeof item !== 'string') {
return false
}
will not stop the foreach.
So the function will return true even if the array does contain none string values.
This seems to wok for me:
function isStringArray(value: any): value is number {
if (Object.prototype.toString.call(value) === '[object Array]') {
if (value.length < 1) {
return false;
} else {
return value.every((d: any) => typeof d === 'string');
}
}
return false;
}
Greetings, Hans
add a comment |
there is a little problem here because the
if (typeof item !== 'string') {
return false
}
will not stop the foreach.
So the function will return true even if the array does contain none string values.
This seems to wok for me:
function isStringArray(value: any): value is number {
if (Object.prototype.toString.call(value) === '[object Array]') {
if (value.length < 1) {
return false;
} else {
return value.every((d: any) => typeof d === 'string');
}
}
return false;
}
Greetings, Hans
add a comment |
there is a little problem here because the
if (typeof item !== 'string') {
return false
}
will not stop the foreach.
So the function will return true even if the array does contain none string values.
This seems to wok for me:
function isStringArray(value: any): value is number {
if (Object.prototype.toString.call(value) === '[object Array]') {
if (value.length < 1) {
return false;
} else {
return value.every((d: any) => typeof d === 'string');
}
}
return false;
}
Greetings, Hans
there is a little problem here because the
if (typeof item !== 'string') {
return false
}
will not stop the foreach.
So the function will return true even if the array does contain none string values.
This seems to wok for me:
function isStringArray(value: any): value is number {
if (Object.prototype.toString.call(value) === '[object Array]') {
if (value.length < 1) {
return false;
} else {
return value.every((d: any) => typeof d === 'string');
}
}
return false;
}
Greetings, Hans
edited Sep 14 '17 at 5:24
answered Sep 11 '17 at 22:31
hanshans
819914
819914
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%2f23130292%2ftest-for-array-of-string-type-in-typescript%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
possible duplicate of How do you check if a variable is an array in JavaScript?
– WiredPrairie
Apr 17 '14 at 10:48
As TypeScript just compiles to JavaScript, the answers may be found by searching for a JavaScript solution. Further, it's worth it to see some of the answers as the answer depends on the host and how it's being used and passed.
– WiredPrairie
Apr 17 '14 at 10:50